11resource "aws_security_group" "bastion" {
2- name = " ${ var . name } "
3- vpc_id = " ${ var . vpc_id } "
2+ name = var. name
3+ vpc_id = var. vpc_id
44 description = " Bastion security group (only SSH inbound access is allowed)"
55
66 tags {
7- Name = " ${ var . name } "
7+ Name = var. name
88 }
99
1010 ingress {
1111 protocol = " tcp"
1212 from_port = 22
1313 to_port = 22
1414
15- cidr_blocks = " ${ var . allow_ssh_cidrs } "
15+ cidr_blocks = var. allow_ssh_cidrs
1616 }
1717
1818 egress {
@@ -31,48 +31,48 @@ resource "aws_security_group" "bastion" {
3131}
3232
3333data "template_file" "user_data" {
34- template = " ${ file (" ${ path . module } /user-data/user-data.sh" )} "
35-
36- vars {
37- s3_bucket_name = " ${ var . s3_bucket_name } "
38- s3_bucket_uri = " ${ var . s3_bucket_uri } "
39- ssh_user = " ${ var . ssh_user } "
40- keys_update_frequency = " ${ var . keys_update_frequency } "
41- enable_hourly_cron_updates = " ${ var . enable_hourly_cron_updates } "
42- additional_user_data_script = " ${ var . additional_user_data_script } "
34+ template = file (" ${ path . module } /user-data/user-data.sh" )
35+
36+ vars = {
37+ s3_bucket_name = var.s3_bucket_name
38+ s3_bucket_uri = var.s3_bucket_uri
39+ ssh_user = var.ssh_user
40+ keys_update_frequency = var.keys_update_frequency
41+ enable_hourly_cron_updates = var.enable_hourly_cron_updates
42+ additional_user_data_script = var.additional_user_data_script
4343 }
4444}
4545
4646resource "aws_launch_configuration" "bastion" {
47- name_prefix = " ${ var . name } "
48- image_id = " ${ var . ami } "
49- instance_type = " ${ var . instance_type } "
50- key_name = " ${ var . keypair } "
51- user_data = " ${ data . template_file . user_data . rendered } "
52- associate_public_ip_address = " ${ var . associate_public_ip_address } "
47+ name_prefix = var. name
48+ image_id = var. ami
49+ instance_type = var. instance_type
50+ key_name = var. keypair
51+ user_data = data. template_file . user_data . rendered
52+ associate_public_ip_address = var. associate_public_ip_address
5353
5454 security_groups = [
55- " ${ compact (concat (list (aws_security_group. bastion . id ), split (" ," , " ${ var . security_group_ids } " )))} " ,
55+ compact (concat (list (aws_security_group. bastion . id ), split (" ," , var. security_group_ids ))),
5656 ]
5757
58- iam_instance_profile = " ${ aws_iam_instance_profile . s3_readonly . name } "
58+ iam_instance_profile = aws_iam_instance_profile. s3_readonly . name
5959
6060 lifecycle {
6161 create_before_destroy = true
6262 }
6363}
6464
6565resource "aws_autoscaling_group" "bastion" {
66- name = " ${ var . name } "
67- vpc_zone_identifier = [" ${ split (" ," , var. subnet_ids )} " ]
66+ name = var. name
67+ vpc_zone_identifier = [split (" ," , var. subnet_ids )]
6868 desired_capacity = " 1"
6969 min_size = " 1"
7070 max_size = " 1"
7171 health_check_grace_period = " 60"
7272 health_check_type = " EC2"
7373 force_delete = false
7474 wait_for_capacity_timeout = 0
75- launch_configuration = " ${ aws_launch_configuration . bastion . name } "
75+ launch_configuration = aws_launch_configuration. bastion . name
7676
7777 enabled_metrics = [
7878 " GroupMinSize" ,
@@ -87,13 +87,13 @@ resource "aws_autoscaling_group" "bastion" {
8787
8888 tag {
8989 key = " Name"
90- value = " ${ var . name } "
90+ value = var. name
9191 propagate_at_launch = true
9292 }
9393
9494 tag {
9595 key = " EIP"
96- value = " ${ var . eip } "
96+ value = var. eip
9797 propagate_at_launch = true
9898 }
9999
0 commit comments