Skip to content

Commit

Permalink
Merge pull request #76 from rackspace-infrastructure-automation/examples
Browse files Browse the repository at this point in the history
Update examples
  • Loading branch information
cwgem committed Aug 4, 2020
2 parents 7fde7c7 + c0eb43c commit 46d0c6d
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 11 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module "ar" {
ec2_os = "amazon"
subnets = module.vpc.private_subnets
image_id = var.image_id
name = "my_ar_instance"
security_groups = [module.sg.private_web_security_group_id]
}
Expand Down
127 changes: 127 additions & 0 deletions examples/custom_ami.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
provider "aws" {
version = "~> 2.7"
region = "us-west-2"
}

module "vpc" {
source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-vpc_basenetwork?ref=v0.12.1"

name = "EC2-AR-BaseNetwork-Test1"
}

data "aws_region" "current_region" {
}

data "aws_ami" "my_custom_ami" {
executable_users = ["self"]
most_recent = true
owners = ["self"]

filter {
name = "name"
values = ["MyCustomAMI"]
}
}

data "aws_ami" "community_ami" {
most_recent = true
owners = ["679593333241"]

filter {
name = "name"
values = ["CentOS Linux 7 x86_64 HVM EBS*"]
}
}

module "ec2_ar" {
source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-ec2_autorecovery?ref=v0.12.10"

backup_tag_value = "False"
detailed_monitoring = true
ec2_os = "centos7"
enable_ebs_optimization = false
encrypt_secondary_ebs_volume = false
image_id = data.aws_ami.community_ami.ami_id
install_codedeploy_agent = false
instance_count = 3
instance_type = "t2.micro"
key_pair = "CircleCI"
name = "my_test_instance"
primary_ebs_volume_iops = 0
primary_ebs_volume_size = 60
primary_ebs_volume_type = "gp2"
secondary_ebs_volume_iops = 0
secondary_ebs_volume_size = 60
secondary_ebs_volume_type = "gp2"
security_groups = [module.vpc.default_sg]
ssm_patching_group = "Group1Patching"
subnets = module.vpc.public_subnets
tenancy = "default"

# Use Snapshot ID
// use_existing_ebs_snapshot = true
// secondary_ebs_volume_existing_id = "snap-39203923"
environment = "Development"

instance_role_managed_policy_arns = ["arn:aws:iam::aws:policy/AmazonEC2FullAccess", "arn:aws:iam::aws:policy/service-role/AmazonEC2SpotFleetRole", "arn:aws:iam::aws:policy/CloudWatchActionsEC2Access"]
perform_ssm_inventory_tag = true
cloudwatch_log_retention = 30
ssm_association_refresh_rate = "rate(1 day)"

ssm_bootstrap_list = [
{
action = "aws:runDocument",
inputs = {
documentPath = "arn:aws:ssm:${data.aws_region.current_region.name}:507897595701:document/Rack-Install_Package",
documentParameters = {
Packages = "bind bindutils"
},
documentType = "SSMDocument"
},
name = "InstallBindAndTools",
timeoutSeconds = 300
},
{
action = "aws:runDocument",
inputs = {
documentPath = "AWS-RunShellScript",
documentParameters = {
commands = ["touch /tmp/myfile"]
},
documentType = "SSMDocument"
},
name = "CreateFile",
timeoutSeconds = 300
},
]

creation_policy_timeout = "20m"
cw_cpu_high_evaluations = 15
cw_cpu_high_operator = "GreaterThanThreshold"
cw_cpu_high_period = 60
cw_cpu_high_threshold = 90
disable_api_termination = false
eip_allocation_id_count = 3
eip_allocation_id_list = aws_eip.my_eips.*.id
notification_topic = ""
private_ip_address = ["172.18.0.5", "172.18.4.5", "172.18.0.6"]
t2_unlimited_mode = "standard"

tags = {
MyTag1 = "MyValue1"
MyTag2 = "MyValue2"
MyTag3 = "MyValue3"
}
}

resource "aws_eip" "my_eips" {
count = 3

vpc = true

tags = {
Purpose = "my managed instance EIP"
Name = "MyManagedInstanceEIP-${format("%03d", count.index + 1)}"
}

}
21 changes: 12 additions & 9 deletions examples/unmanaged.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@ module "vpc" {
name = "EC2-AR-BaseNetwork-Test1"
}

data "aws_region" "current_region" {
}

module "sns" {
source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-sns//?ref=v0.12.1"
source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-sns?ref=v0.12.1"

name = "my-alarm-notification-topic"
}

module "unmanaged_ar" {
source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-ec2_autorecovery?ref=v0.12.10"

ec2_os = "centos7"
instance_count = 1
instance_type = "t2.micro"
notification_topic = module.sns.topic_arn
rackspace_managed = false
resource_name = "my_unmanaged_instance"
security_group_list = [module.vpc.default_sg]
subnets = module.vpc.private_subnets
ec2_os = "centos7"
instance_count = 1
instance_type = "t2.micro"
notification_topic = module.sns.topic_arn
rackspace_managed = false
name = "my_unmanaged_instance"
security_groups = [module.vpc.default_sg]
subnets = module.vpc.private_subnets
}
1 change: 0 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*
* ec2_os = "amazon"
* subnets = module.vpc.private_subnets
* image_id = var.image_id
* name = "my_ar_instance"
* security_groups = [module.sg.private_web_security_group_id]
* }
Expand Down

0 comments on commit 46d0c6d

Please sign in to comment.