Skip to content

Commit

Permalink
Added option to use IP address instead of DNS name as connection point
Browse files Browse the repository at this point in the history
  • Loading branch information
s2504s authored Sep 4, 2017
1 parent 11fa75f commit 05490c3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 30 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ module "efs_backup" {
region = "${var.region}"
vpc_id = "${var.vpc_id}"
efs_mount_target_id = "${var.efs_mount_target_id}"
use_ip_address = true
noncurrent_version_expiration_days = "${var.noncurrent_version_expiration_days}"
ssh_key_pair = "${var.ssh_key_pair}"
datapipeline_config = "${var.datapipeline_config}"
modify_security_group = true
}
output "efs_backup_security_group" {
value = "${module.efs_backup.security_group_id}"
}
Expand All @@ -47,6 +47,7 @@ output "efs_backup_security_group" {
| region | `us-east-1` | AWS Region where module should operate (e.g. `us-east-1`) | Yes |
| vpc_id | `` | AWS VPC ID where module should operate (e.g. `vpc-a22222ee`) | Yes |
| efs_mount_target_id | `` | Elastic File System Mount Target ID (e.g. `fsmt-279bfc62`) | Yes |
| use_ip_address | `false` | If set to `true` will be used IP address instead DNS name of Elastic File System | Yes |
| modify_security_group | `false` | Should the module modify EFS security groups (if set to `false` backups will fail) | Yes |
| noncurrent_version_expiration_days | `3` | S3 object versions expiration period (days) | Yes |
| ssh_key_pair | `` | A ssh key that will be deployed on DataPipeline's instance | Yes |
Expand Down
2 changes: 1 addition & 1 deletion cloudformation.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resource "aws_cloudformation_stack" "datapipeline" {
myInstanceType = "${var.datapipeline_config["instance_type"]}"
mySubnetId = "${data.aws_subnet_ids.default.ids[0]}"
mySecurityGroupId = "${aws_security_group.datapipeline.id}"
myEFSId = "${data.aws_efs_mount_target.default.file_system_id}"
myEFSHost = "${var.use_ip_address ? data.aws_efs_mount_target.default.ip_address : data.aws_efs_mount_target.default.dns_name }"
myS3BackupsBucket = "${aws_s3_bucket.backups.id}"
myRegion = "${var.region}"
myImageId = "${data.aws_ami.amazon_linux.id}"
Expand Down
15 changes: 7 additions & 8 deletions templates/datapipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Parameters:
Type: AWS::EC2::Subnet::Id
myInstanceType:
Type: String
myEFSId:
myEFSHost:
Type: String
myRegion:
Type: String
Expand Down Expand Up @@ -97,20 +97,19 @@ Resources:
RefValue: EC2ResourceObj
- Key: command
StringValue: |
efs_id="$1"
source="$1"
region="$2"
destination="$3"
source="${efs_id}.efs.${region}.amazonaws.com"
sudo yum -y install nfs-utils
[[ -d /backup ]] || sudo mkdir /backup
if ! mount -l -t nfs4 | grep -qF $source; then
sudo mount -t nfs -o nfsvers=4.1 -o rsize=1048576 -o wsize=1048576 -o timeo=600 -o retrans=2 -o hard "$source":/ /backup
fi
sudo aws s3 sync --delete --exact-timestamps /backup/ s3://$destination/${efs_id}/
sudo aws s3 sync --delete --exact-timestamps /backup/ s3://$destination/
backup_status="$?"
exit "$backup_status"
- Key: scriptArgument
StringValue: "#{myEFSId}"
StringValue: "#{myEFSHost}"
- Key: scriptArgument
StringValue: "#{myRegion}"
- Key: scriptArgument
Expand Down Expand Up @@ -196,7 +195,7 @@ Resources:
StringValue: sg-1111111b
- Key: description
StringValue: Security group that can connect to the Production/Backup EFS mount point.
- Id: myEFSId
- Id: myEFSHost
Attributes:
- Key: type
StringValue: String
Expand Down Expand Up @@ -283,8 +282,8 @@ Resources:
StringValue: !Ref mySubnetId
- Id: mySecurityGroupId
StringValue: !Ref mySecurityGroupId
- Id: myEFSId
StringValue: !Ref myEFSId
- Id: myEFSHost
StringValue: !Ref myEFSHost
- Id: myRegion
StringValue: !Ref myRegion
- Id: myS3BackupsBucket
Expand Down
30 changes: 10 additions & 20 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
variable "name" {
default = ""
}
variable "name" {}

variable "namespace" {
default = ""
}
variable "namespace" {}

variable "stage" {
default = ""
}
variable "stage" {}

variable "region" {
default = "us-east-1"
}
variable "region" {}

variable "vpc_id" {
default = ""
variable "vpc_id" {}

variable "use_ip_address" {
default = false
}

variable "datapipeline_config" {
Expand All @@ -28,18 +22,14 @@ variable "datapipeline_config" {
}
}

variable "efs_mount_target_id" {
default = ""
}
variable "efs_mount_target_id" {}

variable "modify_security_group" {
default = false
}

# Set a name of ssh key that will be deployed on DataPipeline's instance. The key should be present in AWS.
variable "ssh_key_pair" {
default = ""
}
variable "ssh_key_pair" {}

variable "noncurrent_version_expiration_days" {
default = "35"
Expand Down

0 comments on commit 05490c3

Please sign in to comment.