Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create AWS cloud resources to access the ElastiCache cluster from Amazon EC2 instances. #40

Merged
merged 19 commits into from
Dec 13, 2023

Conversation

kunduso
Copy link
Owner

@kunduso kunduso commented Dec 13, 2023

The changes in this PR:

  1. create an internet gateway and update the path in the route table attached to the public subnet
  2. create an IAM instance profile and attach an IAM role with the two existing IAM policies to read from the SSM parameter store and AWS Secrets manager. These resources have the ElastiCache endpoint and auth_token stored.
  3. create two Amazon EC2 instances in the public subnet with separate user data scripts to install Python libraries and create Python files inside the instances.

This PR closes #14

@kunduso kunduso self-assigned this Dec 13, 2023
Comment on lines +46 to +73
resource "aws_instance" "app-server-read" {
instance_type = var.instance_type
ami = data.aws_ami.amazon_ami.id
vpc_security_group_ids = [aws_security_group.ec2_instance.id]
iam_instance_profile = aws_iam_instance_profile.ec2_profile.name
associate_public_ip_address = true
#checkov:skip=CKV_AWS_88: Required for Session Manager access
subnet_id = aws_subnet.public[0].id
ebs_optimized = true
monitoring = true
root_block_device {
encrypted = true
}
metadata_options {
http_endpoint = "enabled"
http_tokens = "required"
}
tags = {
Name = "app-4-server-read"
}
user_data = templatefile("user_data/read_elasticache.tpl",
{
Region = var.region,
elasticache_ep = aws_ssm_parameter.elasticache_ep.name,
elasticache_ep_port = aws_ssm_parameter.elasticache_port.name,
elasticache_auth_token = aws_secretsmanager_secret.elasticache_auth.name
})
}

Check warning

Code scanning / checkov

EC2 instance should not have public IP. Warning

EC2 instance should not have public IP.
Comment on lines +74 to +101
resource "aws_instance" "app-server-write" {
instance_type = var.instance_type
ami = data.aws_ami.amazon_ami.id
vpc_security_group_ids = [aws_security_group.ec2_instance.id]
iam_instance_profile = aws_iam_instance_profile.ec2_profile.name
associate_public_ip_address = true
#checkov:skip=CKV_AWS_88: Required for Session Manager access
subnet_id = aws_subnet.public[0].id
ebs_optimized = true
monitoring = true
root_block_device {
encrypted = true
}
metadata_options {
http_endpoint = "enabled"
http_tokens = "required"
}
tags = {
Name = "app-4-server-write"
}
user_data = templatefile("user_data/write_elasticache.tpl",
{
Region = var.region,
elasticache_ep = aws_ssm_parameter.elasticache_ep.name,
elasticache_ep_port = aws_ssm_parameter.elasticache_port.name,
elasticache_auth_token = aws_secretsmanager_secret.elasticache_auth.name
})
}

Check warning

Code scanning / checkov

EC2 instance should not have public IP. Warning

EC2 instance should not have public IP.
Copy link
Contributor

github-actions bot commented Dec 13, 2023

Infracost report

💰 Monthly cost will increase by $67 📈

Project Cost change New monthly cost
kunduso/amazon-elasticache-redis-tf/TFplan.JSON +$67 (+29%) $292
Cost details
──────────────────────────────────
Project: kunduso/amazon-elasticache-redis-tf/TFplan.JSON

+ aws_instance.app-server-read
  +$33

    + Instance usage (Linux/UNIX, on-demand, t3.medium)
      +$30

    + EC2 detailed monitoring
      +$2

    + CPU credits
      $0.00

    + root_block_device
    
        + Storage (general purpose SSD, gp2)
          +$0.80

+ aws_instance.app-server-write
  +$33

    + Instance usage (Linux/UNIX, on-demand, t3.medium)
      +$30

    + EC2 detailed monitoring
      +$2

    + CPU credits
      $0.00

    + root_block_device
    
        + Storage (general purpose SSD, gp2)
          +$0.80

Monthly cost change for kunduso/amazon-elasticache-redis-tf/TFplan.JSON
Amount:  +$67 ($226 → $292)
Percent: +29%

──────────────────────────────────
Key: ~ changed, + added, - removed

40 cloud resources were detected:
∙ 8 were estimated, 6 of which include usage-based costs, see https://infracost.io/usage-file
∙ 31 were free:
  ∙ 4 x aws_route_table
  ∙ 4 x aws_route_table_association
  ∙ 4 x aws_subnet
  ∙ 3 x aws_iam_role_policy_attachment
  ∙ 2 x aws_iam_policy
  ∙ 2 x aws_kms_alias
  ∙ 2 x aws_security_group
  ∙ 2 x aws_ssm_parameter
  ∙ 1 x aws_default_security_group
  ∙ 1 x aws_elasticache_subnet_group
  ∙ 1 x aws_iam_instance_profile
  ∙ 1 x aws_iam_role
  ∙ 1 x aws_internet_gateway
  ∙ 1 x aws_route
  ∙ 1 x aws_secretsmanager_secret_version
  ∙ 1 x aws_vpc
∙ 1 is not supported yet, see https://infracost.io/requested-resources:
  ∙ 1 x aws_kms_key_policy

Infracost estimate: Monthly cost will increase by $67 ↑
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓
┃ Project                                            ┃ Cost change ┃ New monthly cost ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━┫
┃ kunduso/amazon-elasticache-redis-tf/TFplan.JSON    ┃ +$67 (+29%) ┃ $292             ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━┛
This comment will be updated when code changes.

Copy link
Contributor

Terraform Format and Style 🖌success

Terraform Initialization ⚙️success

Terraform Plan 📖success

Terraform Validation 🤖success

Show Plan

terraform
random_password.auth: Refreshing state... [id=none]
data.aws_availability_zones.available: Reading...
data.aws_caller_identity.current: Reading...
data.aws_ami.amazon_ami: Reading...
aws_kms_key.encryption_rest: Refreshing state... [id=624af10a-9d39-4f81-ad00-09dd8d439885]
aws_iam_role.ec2_role: Refreshing state... [id=app-4-ec2-role]
aws_vpc.this: Refreshing state... [id=vpc-01de06becdba1d3e3]
aws_kms_key.encryption_secret: Refreshing state... [id=f85a88f9-9111-46ea-b982-eac7d746d5b4]
aws_secretsmanager_secret.elasticache_auth: Refreshing state... [id=arn:aws:secretsmanager:us-east-2:743794601996:secret:app-4-elasticache-auth-wx4d1f]
aws_kms_alias.encryption_rest: Refreshing state... [id=alias/elasticache-app-4-at-rest]
aws_kms_alias.encryption_secret: Refreshing state... [id=alias/elasticache-app-4-in-transit]
aws_cloudwatch_log_group.slow_log: Refreshing state... [id=/elasticache/app-4-redis-cluster/slow-log]
aws_cloudwatch_log_group.engine_log: Refreshing state... [id=/elasticache/app-4-redis-cluster/engine-log]
data.aws_availability_zones.available: Read complete after 0s [id=us-east-2]
data.aws_caller_identity.current: Read complete after 0s [id=743794601996]
aws_kms_key_policy.encryption_rest_policy: Refreshing state... [id=624af10a-9d39-4f81-ad00-09dd8d439885]
data.aws_ami.amazon_ami: Read complete after 0s [id=ami-0ec5c7d8262c1f6b2]
aws_iam_role_policy_attachment.custom: Refreshing state... [id=app-4-ec2-role-20231211171356953100000002]
aws_iam_instance_profile.ec2_profile: Refreshing state... [id=app-4-ec2-profile]
aws_secretsmanager_secret_version.auth: Refreshing state... [id=arn:aws:secretsmanager:us-east-2:743794601996:secret:app-4-elasticache-auth-wx4d1f|84D33659-CAB0-42CE-8BDF-263E487A161A]
aws_iam_policy.secret_manager_policy: Refreshing state... [id=arn:aws:iam::743794601996:policy/app-4-secret-read-policy]
aws_iam_role_policy_attachment.secret_policy_attachement: Refreshing state... [id=app-4-ec2-role-20231211171356808300000001]
aws_default_security_group.default: Refreshing state... [id=sg-00c03a331f28bdf4b]
aws_security_group.elasticache: Refreshing state... [id=sg-0ebe81ff83e813eb8]
aws_subnet.public[0]: Refreshing state... [id=subnet-0c3049a8821bcc98c]
aws_subnet.private[0]: Refreshing state... [id=subnet-084342d3ba201bfe9]
aws_route_table.private[1]: Refreshing state... [id=rtb-0c66cf1b03f5a174e]
aws_route_table.private[2]: Refreshing state... [id=rtb-06b80b26b777a5f0a]
aws_subnet.private[1]: Refreshing state... [id=subnet-0759d81f1c345a0dd]
aws_route_table.private[0]: Refreshing state... [id=rtb-05fb632dd9719cf47]
aws_subnet.private[2]: Refreshing state... [id=subnet-0de88a416123a72f0]
aws_route_table.public: Refreshing state... [id=rtb-0a9a56bbaa9f1abf8]
aws_route_table_association.public[0]: Refreshing state... [id=rtbassoc-0e68440089e90f44b]
aws_route_table_association.private[2]: Refreshing state... [id=rtbassoc-0e8da7db97d33f32a]
aws_elasticache_subnet_group.elasticache_subnet: Refreshing state... [id=app-4-cache-subnet]
aws_route_table_association.private[1]: Refreshing state... [id=rtbassoc-0e696b9622482b55e]
aws_route_table_association.private[0]: Refreshing state... [id=rtbassoc-05a15917877c2e011]
aws_elasticache_replication_group.app4: Refreshing state... [id=app-4-redis-cluster]
aws_ssm_parameter.elasticache_port: Refreshing state... [id=/elasticache/app-4/app-4-redis-cluster/port]
aws_ssm_parameter.elasticache_ep: Refreshing state... [id=/elasticache/app-4/app-4-redis-cluster/endpoint]
aws_iam_policy.ssm_parameter_policy: Refreshing state... [id=arn:aws:iam::743794601996:policy/app-4-ssm-parameter-read-policy]
aws_iam_role_policy_attachment.ssm_policy_attachement: Refreshing state... [id=app-4-ec2-role-20231211171356982800000003]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_instance.app-server-read will be created
  + resource "aws_instance" "app-server-read" {
      + ami                                  = "ami-0ec5c7d8262c1f6b2"
      + arn                                  = (known after apply)
      + associate_public_ip_address          = true
      + availability_zone                    = (known after apply)
      + cpu_core_count                       = (known after apply)
      + cpu_threads_per_core                 = (known after apply)
      + disable_api_stop                     = (known after apply)
      + disable_api_termination              = (known after apply)
      + ebs_optimized                        = true
      + get_password_data                    = false
      + host_id                              = (known after apply)
      + host_resource_group_arn              = (known after apply)
      + iam_instance_profile                 = "app-4-ec2-profile"
      + id                                   = (known after apply)
      + instance_initiated_shutdown_behavior = (known after apply)
      + instance_lifecycle                   = (known after apply)
      + instance_state                       = (known after apply)
      + instance_type                        = "t3.medium"
      + ipv6_address_count                   = (known after apply)
      + ipv6_addresses                       = (known after apply)
      + key_name                             = (known after apply)
      + monitoring                           = true
      + outpost_arn                          = (known after apply)
      + password_data                        = (known after apply)
      + placement_group                      = (known after apply)
      + placement_partition_number           = (known after apply)
      + primary_network_interface_id         = (known after apply)
      + private_dns                          = (known after apply)
      + private_ip                           = (known after apply)
      + public_dns                           = (known after apply)
      + public_ip                            = (known after apply)
      + secondary_private_ips                = (known after apply)
      + security_groups                      = (known after apply)
      + source_dest_check                    = true
      + spot_instance_request_id             = (known after apply)
      + subnet_id                            = "subnet-0c3049a8821bcc98c"
      + tags                                 = {
          + "Name" = "app-4-server-read"
        }
      + tags_all                             = {
          + "Name"   = "app-4-server-read"
          + "Source" = "https://github.com/kunduso/amazon-elasticache-redis-tf"
        }
      + tenancy                              = (known after apply)
      + user_data                            = "3bdca51f907da8d56aa6517b515e0e33153f53cd"
      + user_data_base64                     = (known after apply)
      + user_data_replace_on_change          = false
      + vpc_security_group_ids               = (known after apply)

      + metadata_options {
          + http_endpoint               = "enabled"
          + http_protocol_ipv6          = "disabled"
          + http_put_response_hop_limit = (known after apply)
          + http_tokens                 = "required"
          + instance_metadata_tags      = (known after apply)
        }

      + root_block_device {
          + delete_on_termination = true
          + device_name           = (known after apply)
          + encrypted             = true
          + iops                  = (known after apply)
          + kms_key_id            = (known after apply)
          + throughput            = (known after apply)
          + volume_id             = (known after apply)
          + volume_size           = (known after apply)
          + volume_type           = (known after apply)
        }
    }

  # aws_instance.app-server-write will be created
  + resource "aws_instance" "app-server-write" {
      + ami                                  = "ami-0ec5c7d8262c1f6b2"
      + arn                                  = (known after apply)
      + associate_public_ip_address          = true
      + availability_zone                    = (known after apply)
      + cpu_core_count                       = (known after apply)
      + cpu_threads_per_core                 = (known after apply)
      + disable_api_stop                     = (known after apply)
      + disable_api_termination              = (known after apply)
      + ebs_optimized                        = true
      + get_password_data                    = false
      + host_id                              = (known after apply)
      + host_resource_group_arn              = (known after apply)
      + iam_instance_profile                 = "app-4-ec2-profile"
      + id                                   = (known after apply)
      + instance_initiated_shutdown_behavior = (known after apply)
      + instance_lifecycle                   = (known after apply)
      + instance_state                       = (known after apply)
      + instance_type                        = "t3.medium"
      + ipv6_address_count                   = (known after apply)
      + ipv6_addresses                       = (known after apply)
      + key_name                             = (known after apply)
      + monitoring                           = true
      + outpost_arn                          = (known after apply)
      + password_data                        = (known after apply)
      + placement_group                      = (known after apply)
      + placement_partition_number           = (known after apply)
      + primary_network_interface_id         = (known after apply)
      + private_dns                          = (known after apply)
      + private_ip                           = (known after apply)
      + public_dns                           = (known after apply)
      + public_ip                            = (known after apply)
      + secondary_private_ips                = (known after apply)
      + security_groups                      = (known after apply)
      + source_dest_check                    = true
      + spot_instance_request_id             = (known after apply)
      + subnet_id                            = "subnet-0c3049a8821bcc98c"
      + tags                                 = {
          + "Name" = "app-4-server-write"
        }
      + tags_all                             = {
          + "Name"   = "app-4-server-write"
          + "Source" = "https://github.com/kunduso/amazon-elasticache-redis-tf"
        }
      + tenancy                              = (known after apply)
      + user_data                            = "9a9c6823af09d9396fdd63d1f6328e39dd9d034f"
      + user_data_base64                     = (known after apply)
      + user_data_replace_on_change          = false
      + vpc_security_group_ids               = (known after apply)

      + metadata_options {
          + http_endpoint               = "enabled"
          + http_protocol_ipv6          = "disabled"
          + http_put_response_hop_limit = (known after apply)
          + http_tokens                 = "required"
          + instance_metadata_tags      = (known after apply)
        }

      + root_block_device {
          + delete_on_termination = true
          + device_name           = (known after apply)
          + encrypted             = true
          + iops                  = (known after apply)
          + kms_key_id            = (known after apply)
          + throughput            = (known after apply)
          + volume_id             = (known after apply)
          + volume_size           = (known after apply)
          + volume_type           = (known after apply)
        }
    }

  # aws_internet_gateway.this-igw will be created
  + resource "aws_internet_gateway" "this-igw" {
      + arn      = (known after apply)
      + id       = (known after apply)
      + owner_id = (known after apply)
      + tags     = {
          + "Name" = "app-4-gateway"
        }
      + tags_all = {
          + "Name"   = "app-4-gateway"
          + "Source" = "https://github.com/kunduso/amazon-elasticache-redis-tf"
        }
      + vpc_id   = "vpc-01de06becdba1d3e3"
    }

  # aws_route.internet-route will be created
  + resource "aws_route" "internet-route" {
      + destination_cidr_block = "0.0.0.0/0"
      + gateway_id             = (known after apply)
      + id                     = (known after apply)
      + instance_id            = (known after apply)
      + instance_owner_id      = (known after apply)
      + network_interface_id   = (known after apply)
      + origin                 = (known after apply)
      + route_table_id         = "rtb-0a9a56bbaa9f1abf8"
      + state                  = (known after apply)
    }

  # aws_security_group.ec2_instance will be created
  + resource "aws_security_group" "ec2_instance" {
      + arn                    = (known after apply)
      + description            = "Allow inbound to and outbound access from the Amazon EC2 instance."
      + egress                 = [
          + {
              + cidr_blocks      = [
                  + "0.0.0.0/0",
                ]
              + description      = "Enable access to the internet."
              + from_port        = 0
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "-1"
              + security_groups  = []
              + self             = false
              + to_port          = 0
            },
        ]
      + id                     = (known after apply)
      + ingress                = [
          + {
              + cidr_blocks      = [
                  + "10.20.32.0/25",
                ]
              + description      = "Enable access from any resource inside the VPC."
              + from_port        = 0
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "-1"
              + security_groups  = []
              + self             = false
              + to_port          = 0
            },
        ]
      + name                   = "app-4-ec2"
      + name_prefix            = (known after apply)
      + owner_id               = (known after apply)
      + revoke_rules_on_delete = false
      + tags_all               = {
          + "Source" = "https://github.com/kunduso/amazon-elasticache-redis-tf"
        }
      + vpc_id                 = "vpc-01de06becdba1d3e3"
    }

Plan: 5 to add, 0 to change, 0 to destroy.

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: TFplan.JSON

To perform exactly these actions, run the following command to apply:
    terraform apply "TFplan.JSON"

Pushed by: @kunduso, Action: pull_request

Copy link
Contributor

Terraform Format and Style 🖌success

Terraform Initialization ⚙️success

Terraform Plan 📖success

Terraform Validation 🤖success

Show Plan

terraform
random_password.auth: Refreshing state... [id=none]
data.aws_caller_identity.current: Reading...
aws_vpc.this: Refreshing state... [id=vpc-01de06becdba1d3e3]
aws_kms_key.encryption_secret: Refreshing state... [id=f85a88f9-9111-46ea-b982-eac7d746d5b4]
data.aws_availability_zones.available: Reading...
data.aws_ami.amazon_ami: Reading...
aws_iam_role.ec2_role: Refreshing state... [id=app-4-ec2-role]
aws_kms_key.encryption_rest: Refreshing state... [id=624af10a-9d39-4f81-ad00-09dd8d439885]
data.aws_caller_identity.current: Read complete after 0s [id=743794601996]
data.aws_availability_zones.available: Read complete after 0s [id=us-east-2]
aws_iam_role_policy_attachment.custom: Refreshing state... [id=app-4-ec2-role-20231211171356953100000002]
aws_iam_instance_profile.ec2_profile: Refreshing state... [id=app-4-ec2-profile]
aws_kms_alias.encryption_secret: Refreshing state... [id=alias/elasticache-app-4-in-transit]
aws_secretsmanager_secret.elasticache_auth: Refreshing state... [id=arn:aws:secretsmanager:us-east-2:743794601996:secret:app-4-elasticache-auth-wx4d1f]
aws_cloudwatch_log_group.engine_log: Refreshing state... [id=/elasticache/app-4-redis-cluster/engine-log]
aws_kms_key_policy.encryption_rest_policy: Refreshing state... [id=624af10a-9d39-4f81-ad00-09dd8d439885]
aws_cloudwatch_log_group.slow_log: Refreshing state... [id=/elasticache/app-4-redis-cluster/slow-log]
aws_kms_alias.encryption_rest: Refreshing state... [id=alias/elasticache-app-4-at-rest]
data.aws_ami.amazon_ami: Read complete after 0s [id=ami-0ec5c7d8262c1f6b2]
aws_secretsmanager_secret_version.auth: Refreshing state... [id=arn:aws:secretsmanager:us-east-2:743794601996:secret:app-4-elasticache-auth-wx4d1f|84D33659-CAB0-42CE-8BDF-263E487A161A]
aws_iam_policy.secret_manager_policy: Refreshing state... [id=arn:aws:iam::743794601996:policy/app-4-secret-read-policy]
aws_iam_role_policy_attachment.secret_policy_attachement: Refreshing state... [id=app-4-ec2-role-20231211171356808300000001]
aws_default_security_group.default: Refreshing state... [id=sg-00c03a331f28bdf4b]
aws_subnet.private[0]: Refreshing state... [id=subnet-084342d3ba201bfe9]
aws_security_group.elasticache: Refreshing state... [id=sg-0ebe81ff83e813eb8]
aws_route_table.private[2]: Refreshing state... [id=rtb-06b80b26b777a5f0a]
aws_subnet.private[1]: Refreshing state... [id=subnet-0759d81f1c345a0dd]
aws_subnet.public[0]: Refreshing state... [id=subnet-0c3049a8821bcc98c]
aws_route_table.private[0]: Refreshing state... [id=rtb-05fb632dd9719cf47]
aws_subnet.private[2]: Refreshing state... [id=subnet-0de88a416123a72f0]
aws_route_table.private[1]: Refreshing state... [id=rtb-0c66cf1b03f5a174e]
aws_route_table.public: Refreshing state... [id=rtb-0a9a56bbaa9f1abf8]
aws_route_table_association.public[0]: Refreshing state... [id=rtbassoc-0e68440089e90f44b]
aws_route_table_association.private[2]: Refreshing state... [id=rtbassoc-0e8da7db97d33f32a]
aws_route_table_association.private[1]: Refreshing state... [id=rtbassoc-0e696b9622482b55e]
aws_route_table_association.private[0]: Refreshing state... [id=rtbassoc-05a15917877c2e011]
aws_elasticache_subnet_group.elasticache_subnet: Refreshing state... [id=app-4-cache-subnet]
aws_elasticache_replication_group.app4: Refreshing state... [id=app-4-redis-cluster]
aws_ssm_parameter.elasticache_ep: Refreshing state... [id=/elasticache/app-4/app-4-redis-cluster/endpoint]
aws_ssm_parameter.elasticache_port: Refreshing state... [id=/elasticache/app-4/app-4-redis-cluster/port]
aws_iam_policy.ssm_parameter_policy: Refreshing state... [id=arn:aws:iam::743794601996:policy/app-4-ssm-parameter-read-policy]
aws_iam_role_policy_attachment.ssm_policy_attachement: Refreshing state... [id=app-4-ec2-role-20231211171356982800000003]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_instance.app-server-read will be created
  + resource "aws_instance" "app-server-read" {
      + ami                                  = "ami-0ec5c7d8262c1f6b2"
      + arn                                  = (known after apply)
      + associate_public_ip_address          = true
      + availability_zone                    = (known after apply)
      + cpu_core_count                       = (known after apply)
      + cpu_threads_per_core                 = (known after apply)
      + disable_api_stop                     = (known after apply)
      + disable_api_termination              = (known after apply)
      + ebs_optimized                        = true
      + get_password_data                    = false
      + host_id                              = (known after apply)
      + host_resource_group_arn              = (known after apply)
      + iam_instance_profile                 = "app-4-ec2-profile"
      + id                                   = (known after apply)
      + instance_initiated_shutdown_behavior = (known after apply)
      + instance_lifecycle                   = (known after apply)
      + instance_state                       = (known after apply)
      + instance_type                        = "t3.medium"
      + ipv6_address_count                   = (known after apply)
      + ipv6_addresses                       = (known after apply)
      + key_name                             = (known after apply)
      + monitoring                           = true
      + outpost_arn                          = (known after apply)
      + password_data                        = (known after apply)
      + placement_group                      = (known after apply)
      + placement_partition_number           = (known after apply)
      + primary_network_interface_id         = (known after apply)
      + private_dns                          = (known after apply)
      + private_ip                           = (known after apply)
      + public_dns                           = (known after apply)
      + public_ip                            = (known after apply)
      + secondary_private_ips                = (known after apply)
      + security_groups                      = (known after apply)
      + source_dest_check                    = true
      + spot_instance_request_id             = (known after apply)
      + subnet_id                            = "subnet-0c3049a8821bcc98c"
      + tags                                 = {
          + "Name" = "app-4-server-read"
        }
      + tags_all                             = {
          + "Name"   = "app-4-server-read"
          + "Source" = "https://github.com/kunduso/amazon-elasticache-redis-tf"
        }
      + tenancy                              = (known after apply)
      + user_data                            = "3bdca51f907da8d56aa6517b515e0e33153f53cd"
      + user_data_base64                     = (known after apply)
      + user_data_replace_on_change          = false
      + vpc_security_group_ids               = (known after apply)

      + metadata_options {
          + http_endpoint               = "enabled"
          + http_protocol_ipv6          = "disabled"
          + http_put_response_hop_limit = (known after apply)
          + http_tokens                 = "required"
          + instance_metadata_tags      = (known after apply)
        }

      + root_block_device {
          + delete_on_termination = true
          + device_name           = (known after apply)
          + encrypted             = true
          + iops                  = (known after apply)
          + kms_key_id            = (known after apply)
          + throughput            = (known after apply)
          + volume_id             = (known after apply)
          + volume_size           = (known after apply)
          + volume_type           = (known after apply)
        }
    }

  # aws_instance.app-server-write will be created
  + resource "aws_instance" "app-server-write" {
      + ami                                  = "ami-0ec5c7d8262c1f6b2"
      + arn                                  = (known after apply)
      + associate_public_ip_address          = true
      + availability_zone                    = (known after apply)
      + cpu_core_count                       = (known after apply)
      + cpu_threads_per_core                 = (known after apply)
      + disable_api_stop                     = (known after apply)
      + disable_api_termination              = (known after apply)
      + ebs_optimized                        = true
      + get_password_data                    = false
      + host_id                              = (known after apply)
      + host_resource_group_arn              = (known after apply)
      + iam_instance_profile                 = "app-4-ec2-profile"
      + id                                   = (known after apply)
      + instance_initiated_shutdown_behavior = (known after apply)
      + instance_lifecycle                   = (known after apply)
      + instance_state                       = (known after apply)
      + instance_type                        = "t3.medium"
      + ipv6_address_count                   = (known after apply)
      + ipv6_addresses                       = (known after apply)
      + key_name                             = (known after apply)
      + monitoring                           = true
      + outpost_arn                          = (known after apply)
      + password_data                        = (known after apply)
      + placement_group                      = (known after apply)
      + placement_partition_number           = (known after apply)
      + primary_network_interface_id         = (known after apply)
      + private_dns                          = (known after apply)
      + private_ip                           = (known after apply)
      + public_dns                           = (known after apply)
      + public_ip                            = (known after apply)
      + secondary_private_ips                = (known after apply)
      + security_groups                      = (known after apply)
      + source_dest_check                    = true
      + spot_instance_request_id             = (known after apply)
      + subnet_id                            = "subnet-0c3049a8821bcc98c"
      + tags                                 = {
          + "Name" = "app-4-server-write"
        }
      + tags_all                             = {
          + "Name"   = "app-4-server-write"
          + "Source" = "https://github.com/kunduso/amazon-elasticache-redis-tf"
        }
      + tenancy                              = (known after apply)
      + user_data                            = "9a9c6823af09d9396fdd63d1f6328e39dd9d034f"
      + user_data_base64                     = (known after apply)
      + user_data_replace_on_change          = false
      + vpc_security_group_ids               = (known after apply)

      + metadata_options {
          + http_endpoint               = "enabled"
          + http_protocol_ipv6          = "disabled"
          + http_put_response_hop_limit = (known after apply)
          + http_tokens                 = "required"
          + instance_metadata_tags      = (known after apply)
        }

      + root_block_device {
          + delete_on_termination = true
          + device_name           = (known after apply)
          + encrypted             = true
          + iops                  = (known after apply)
          + kms_key_id            = (known after apply)
          + throughput            = (known after apply)
          + volume_id             = (known after apply)
          + volume_size           = (known after apply)
          + volume_type           = (known after apply)
        }
    }

  # aws_internet_gateway.this-igw will be created
  + resource "aws_internet_gateway" "this-igw" {
      + arn      = (known after apply)
      + id       = (known after apply)
      + owner_id = (known after apply)
      + tags     = {
          + "Name" = "app-4-gateway"
        }
      + tags_all = {
          + "Name"   = "app-4-gateway"
          + "Source" = "https://github.com/kunduso/amazon-elasticache-redis-tf"
        }
      + vpc_id   = "vpc-01de06becdba1d3e3"
    }

  # aws_route.internet-route will be created
  + resource "aws_route" "internet-route" {
      + destination_cidr_block = "0.0.0.0/0"
      + gateway_id             = (known after apply)
      + id                     = (known after apply)
      + instance_id            = (known after apply)
      + instance_owner_id      = (known after apply)
      + network_interface_id   = (known after apply)
      + origin                 = (known after apply)
      + route_table_id         = "rtb-0a9a56bbaa9f1abf8"
      + state                  = (known after apply)
    }

  # aws_security_group.ec2_instance will be created
  + resource "aws_security_group" "ec2_instance" {
      + arn                    = (known after apply)
      + description            = "Allow inbound to and outbound access from the Amazon EC2 instance."
      + egress                 = [
          + {
              + cidr_blocks      = [
                  + "0.0.0.0/0",
                ]
              + description      = "Enable access to the internet."
              + from_port        = 0
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "-1"
              + security_groups  = []
              + self             = false
              + to_port          = 0
            },
        ]
      + id                     = (known after apply)
      + ingress                = [
          + {
              + cidr_blocks      = [
                  + "10.20.32.0/25",
                ]
              + description      = "Enable access from any resource inside the VPC."
              + from_port        = 0
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "-1"
              + security_groups  = []
              + self             = false
              + to_port          = 0
            },
        ]
      + name                   = "app-4-ec2"
      + name_prefix            = (known after apply)
      + owner_id               = (known after apply)
      + revoke_rules_on_delete = false
      + tags_all               = {
          + "Source" = "https://github.com/kunduso/amazon-elasticache-redis-tf"
        }
      + vpc_id                 = "vpc-01de06becdba1d3e3"
    }

Plan: 5 to add, 0 to change, 0 to destroy.

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: TFplan.JSON

To perform exactly these actions, run the following command to apply:
    terraform apply "TFplan.JSON"

Pushed by: @kunduso, Action: pull_request

@kunduso kunduso merged commit 75aeafe into main Dec 13, 2023
4 checks passed
@kunduso kunduso deleted the verify-access branch November 19, 2024 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Verify access to the Amazon ElastiCache for Redis cluster
1 participant