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

Add elasticache #9

Merged
merged 5 commits into from
Oct 16, 2023
Merged

Add elasticache #9

merged 5 commits into from
Oct 16, 2023

Conversation

kunduso
Copy link
Owner

@kunduso kunduso commented Oct 16, 2023

This pr closes #8

@kunduso kunduso self-assigned this Oct 16, 2023
Comment on lines +5 to +10
resource "aws_kms_key" "encrytion_rest" {
enable_key_rotation = true
description = "Key to encrypt cache at rest"
deletion_window_in_days = 7
#checkov:skip=CKV2_AWS_64: Not including a KMS Key policy
}

Check warning

Code scanning / checkov

Ensure KMS key Policy is defined Warning

Ensure KMS key Policy is defined
Comment on lines +11 to +16
resource "aws_kms_key" "encrytion_secret" {
enable_key_rotation = true
description = "Key to encrypt secret"
deletion_window_in_days = 7
#checkov:skip=CKV2_AWS_64: Not including a KMS Key policy
}

Check warning

Code scanning / checkov

Ensure KMS key Policy is defined Warning

Ensure KMS key Policy is defined
Comment on lines +17 to +22
resource "aws_secretsmanager_secret" "elasticache_auth" {
name = "elasticache_auth"
recovery_window_in_days = 0
kms_key_id = aws_kms_key.encrytion_secret.id
#checkov:skip=CKV2_AWS_57: Disabled Secrets Manager secrets automatic rotation
}

Check warning

Code scanning / checkov

Ensure Secrets Manager secrets should have automatic rotation enabled Warning

Ensure Secrets Manager secrets should have automatic rotation enabled
@kunduso kunduso temporarily deployed to production October 16, 2023 22:02 — with GitHub Actions Inactive
@github-actions
Copy link
Contributor

💰 Infracost estimate: monthly cost will increase by $226 📈

Project Cost change New monthly cost
kunduso/amazon-elasticache-redis-tf/TFplan.JSON +$226 $226
Infracost output
──────────────────────────────────
Project: kunduso/amazon-elasticache-redis-tf/TFplan.JSON

+ aws_elasticache_replication_group.app4
  +$223

    + ElastiCache (on-demand, cache.t2.small)
      +$223

+ aws_kms_key.encrytion_rest
  +$1

    + Customer master key
      +$1

    + Requests
      Monthly cost depends on usage
        +$0.03 per 10k requests

    + ECC GenerateDataKeyPair requests
      Monthly cost depends on usage
        +$0.10 per 10k requests

    + RSA GenerateDataKeyPair requests
      Monthly cost depends on usage
        +$0.10 per 10k requests

+ aws_kms_key.encrytion_secret
  +$1

    + Customer master key
      +$1

    + Requests
      Monthly cost depends on usage
        +$0.03 per 10k requests

    + ECC GenerateDataKeyPair requests
      Monthly cost depends on usage
        +$0.10 per 10k requests

    + RSA GenerateDataKeyPair requests
      Monthly cost depends on usage
        +$0.10 per 10k requests

+ aws_secretsmanager_secret.elasticache_auth
  +$0.40

    + Secret
      +$0.40

    + API requests
      Monthly cost depends on usage
        +$0.05 per 10k requests

Monthly cost change for kunduso/amazon-elasticache-redis-tf/TFplan.JSON
Amount:  +$226 ($0.00 → $226)

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

21 cloud resources were detected:
∙ 4 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file
∙ 17 were free:
  ∙ 4 x aws_route_table
  ∙ 4 x aws_route_table_association
  ∙ 4 x aws_subnet
  ∙ 1 x aws_default_security_group
  ∙ 1 x aws_elasticache_subnet_group
  ∙ 1 x aws_secretsmanager_secret_version
  ∙ 1 x aws_security_group
  ∙ 1 x aws_vpc

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

@github-actions
Copy link
Contributor

Terraform Format and Style 🖌success

Terraform Initialization ⚙️success

Terraform Plan 📖success

Terraform Validation 🤖success

Show Plan

terraform
data.aws_availability_zones.available: Reading...
aws_vpc.this: Refreshing state... [id=vpc-0aee610d9ee2f5056]
data.aws_availability_zones.available: Read complete after 1s [id=us-east-2]
aws_route_table.public: Refreshing state... [id=rtb-07a879baced138b59]
aws_subnet.private[0]: Refreshing state... [id=subnet-0d793fee34548d46b]
aws_subnet.public[0]: Refreshing state... [id=subnet-01504aaf919b844a2]
aws_subnet.private[1]: Refreshing state... [id=subnet-00445199ef90108e3]
aws_default_security_group.default: Refreshing state... [id=sg-017656e5a4e187b27]
aws_route_table.private[1]: Refreshing state... [id=rtb-09c463d4787f20931]
aws_route_table.private[2]: Refreshing state... [id=rtb-0be19402a8902cddc]
aws_subnet.private[2]: Refreshing state... [id=subnet-052cb9788e3699e42]
aws_route_table.private[0]: Refreshing state... [id=rtb-00fd94662b273fa5f]
aws_route_table_association.private[2]: Refreshing state... [id=rtbassoc-0ec28b2c44b0623b5]
aws_route_table_association.public[0]: Refreshing state... [id=rtbassoc-049a33ab4984be2a1]
aws_route_table_association.private[0]: Refreshing state... [id=rtbassoc-07474438f8d7717f5]
aws_route_table_association.private[1]: Refreshing state... [id=rtbassoc-0a3cfb9c7b6d62162]

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_elasticache_replication_group.app4 will be created
  + resource "aws_elasticache_replication_group" "app4" {
      + apply_immediately              = true
      + arn                            = (known after apply)
      + at_rest_encryption_enabled     = true
      + auth_token                     = (sensitive value)
      + auto_minor_version_upgrade     = (known after apply)
      + automatic_failover_enabled     = true
      + cluster_enabled                = (known after apply)
      + configuration_endpoint_address = (known after apply)
      + data_tiering_enabled           = (known after apply)
      + description                    = "ElastiCache cluster for app4"
      + engine                         = "redis"
      + engine_version                 = (known after apply)
      + engine_version_actual          = (known after apply)
      + global_replication_group_id    = (known after apply)
      + id                             = (known after apply)
      + kms_key_id                     = (known after apply)
      + maintenance_window             = (known after apply)
      + member_clusters                = (known after apply)
      + multi_az_enabled               = true
      + node_type                      = "cache.t2.small"
      + num_cache_clusters             = (known after apply)
      + num_node_groups                = 3
      + parameter_group_name           = "default.redis7.cluster.om"
      + port                           = 6379
      + primary_endpoint_address       = (known after apply)
      + reader_endpoint_address        = (known after apply)
      + replicas_per_node_group        = 2
      + replication_group_id           = "app4-redis-cluster"
      + security_group_ids             = (known after apply)
      + security_group_names           = (known after apply)
      + snapshot_window                = (known after apply)
      + subnet_group_name              = "cache-subnet"
      + tags_all                       = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + transit_encryption_enabled     = true
    }

  # aws_elasticache_subnet_group.elasticache_subnet will be created
  + resource "aws_elasticache_subnet_group" "elasticache_subnet" {
      + arn         = (known after apply)
      + description = "Managed by Terraform"
      + id          = (known after apply)
      + name        = "cache-subnet"
      + subnet_ids  = [
          + "subnet-00445199ef90108e3",
          + "subnet-052cb9788e3699e42",
          + "subnet-0d793fee34548d46b",
        ]
      + tags_all    = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
    }

  # aws_kms_key.encrytion_rest will be created
  + resource "aws_kms_key" "encrytion_rest" {
      + arn                                = (known after apply)
      + bypass_policy_lockout_safety_check = false
      + customer_master_key_spec           = "SYMMETRIC_DEFAULT"
      + deletion_window_in_days            = 7
      + description                        = "Key to encrypt cache at rest"
      + enable_key_rotation                = true
      + id                                 = (known after apply)
      + is_enabled                         = true
      + key_id                             = (known after apply)
      + key_usage                          = "ENCRYPT_DECRYPT"
      + multi_region                       = (known after apply)
      + policy                             = (known after apply)
      + tags_all                           = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
    }

  # aws_kms_key.encrytion_secret will be created
  + resource "aws_kms_key" "encrytion_secret" {
      + arn                                = (known after apply)
      + bypass_policy_lockout_safety_check = false
      + customer_master_key_spec           = "SYMMETRIC_DEFAULT"
      + deletion_window_in_days            = 7
      + description                        = "Key to encrypt secret"
      + enable_key_rotation                = true
      + id                                 = (known after apply)
      + is_enabled                         = true
      + key_id                             = (known after apply)
      + key_usage                          = "ENCRYPT_DECRYPT"
      + multi_region                       = (known after apply)
      + policy                             = (known after apply)
      + tags_all                           = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
    }

  # aws_secretsmanager_secret.elasticache_auth will be created
  + resource "aws_secretsmanager_secret" "elasticache_auth" {
      + arn                            = (known after apply)
      + force_overwrite_replica_secret = false
      + id                             = (known after apply)
      + kms_key_id                     = (known after apply)
      + name                           = "elasticache_auth"
      + name_prefix                    = (known after apply)
      + policy                         = (known after apply)
      + recovery_window_in_days        = 0
      + tags_all                       = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
    }

  # aws_secretsmanager_secret_version.auth will be created
  + resource "aws_secretsmanager_secret_version" "auth" {
      + arn            = (known after apply)
      + id             = (known after apply)
      + secret_id      = (known after apply)
      + secret_string  = (sensitive value)
      + version_id     = (known after apply)
      + version_stages = (known after apply)
    }

  # aws_security_group.elasticache will be created
  + resource "aws_security_group" "elasticache" {
      + arn                    = (known after apply)
      + description            = "Allow inbound to and outbound access from the Amazon ElastiCache cluster."
      + egress                 = [
          + {
              + cidr_blocks      = [
                  + "0.0.0.0/0",
                ]
              + description      = "Enable access to the ElastiCache cluster."
              + 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 an Amazon EC2 instance in the VPC"
              + from_port        = 6379
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "tcp"
              + security_groups  = []
              + self             = false
              + to_port          = 6379
            },
        ]
      + name                   = "app4-elasticache"
      + name_prefix            = (known after apply)
      + owner_id               = (known after apply)
      + revoke_rules_on_delete = false
      + tags_all               = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                 = "vpc-0aee610d9ee2f5056"
    }

Plan: 7 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 4a76831 into main Oct 16, 2023
5 checks passed
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.

Add Amazon ElastiCache for Redis
1 participant