diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..b2fa189 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,47 @@ +name: CI-CD of ECR + +on: + pull_request: + types: [closed] # Use brackets for proper syntax + branches: [main] + +env: + AWS_REGION: us-east-1 + ECR_REPOSITORY_APP: assignmentdocker-dev-ecr-repo + ECR_REPOSITORY_MYSQL: assignmentdocker-dev-mysql-ecr-repo + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + aws-session-token: ${{ secrets.AWS_SESSION_TOKEN }} # Only include if using temporary credentials + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, tag, and push application image to Amazon ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + IMAGE_TAG: ${{ github.sha }} + run: | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY_APP:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY_APP:$IMAGE_TAG + + - name: Build, tag, and push MySQL image to Amazon ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + IMAGE_TAG: ${{ github.sha }} + run: | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY_MYSQL:$IMAGE_TAG -f Dockerfile.mysql . + docker push $ECR_REGISTRY/$ECR_REPOSITORY_MYSQL:$IMAGE_TAG diff --git a/Dockerfile_mysql b/Dockerfile.mysql similarity index 100% rename from Dockerfile_mysql rename to Dockerfile.mysql diff --git a/README.md b/README.md index ed2402b..cf5538f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Install the required MySQL package - +# checked sudo apt-get update -y sudo apt-get install mysql-client -y diff --git a/requirements.txt b/requirements.txt index 81d430f..b00262a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ flask==2.0.3 pymysql==1.0.2 cryptography==38.0.1 +werkzeug==2.0.3 \ No newline at end of file diff --git a/terraform/dev/instances/.gitignore b/terraform/dev/instances/.gitignore new file mode 100644 index 0000000..c189efd --- /dev/null +++ b/terraform/dev/instances/.gitignore @@ -0,0 +1,12 @@ +# Ignore Terraform state and backup files +.terraform + +# Ignore Terraform cache and provider files +.terraform/ + +# Optionally ignore the lock file +.terraform.lock.hcl + +# Exclude SSH keys (if sensitive) +assignmentdocker-dev +assignmentdocker-dev.pub \ No newline at end of file diff --git a/terraform/dev/instances/config.tf b/terraform/dev/instances/config.tf new file mode 100644 index 0000000..e69de29 diff --git a/terraform/dev/instances/main.tf b/terraform/dev/instances/main.tf new file mode 100644 index 0000000..40b31e6 --- /dev/null +++ b/terraform/dev/instances/main.tf @@ -0,0 +1,156 @@ +#---------------------------------------------------------- +# ACS730 - Week 3 - Terraform Introduction +# +# Build EC2 Instances and Create ECR Repository +# +#---------------------------------------------------------- + +#this is for video purpose +# Define the provider +provider "aws" { + region = "us-east-1" +} + +# Data source for AMI id +data "aws_ami" "latest_amazon_linux" { + owners = ["amazon"] + most_recent = true + filter { + name = "name" + values = ["amzn2-ami-hvm-*-x86_64-gp2"] + } +} + +# Data source for availability zones in us-east-1 +data "aws_availability_zones" "available" { + state = "available" +} + +# Data block to retrieve the default VPC id +data "aws_vpc" "default" { + default = true +} + +# Define tags locally +locals { + default_tags = merge(module.globalvars.default_tags, { "env" = var.env }) + prefix = module.globalvars.prefix + name_prefix = "${local.prefix}-${var.env}" +} + +# Retrieve global variables from the Terraform module +module "globalvars" { + source = "../../modules/globalvars" +} + +# Create two more instances +resource "aws_instance" "my_instance_1" { + ami = data.aws_ami.latest_amazon_linux.id + instance_type = lookup(var.instance_type, var.env) + key_name = aws_key_pair.my_key.key_name + vpc_security_group_ids = [aws_security_group.my_sg.id] + associate_public_ip_address = false + + lifecycle { + create_before_destroy = true + } + + tags = merge(local.default_tags, + { + "Name" = "${local.name_prefix}-my-instance-1" + } + ) + user_data = <<-EOF + #!/bin/bash + sudo yum update -y + sudo amazon-linux-extras install docker -y + sudo service docker start + sudo usermod -a -G docker ec2-user + sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + EOF +} + + +# Adding SSH key to Amazon EC2 +resource "aws_key_pair" "my_key" { + key_name = local.name_prefix + public_key = file("${local.name_prefix}.pub") +} + +# Security Group +resource "aws_security_group" "my_sg" { + name = "allow_ssh" + description = "Allow SSH inbound traffic" + vpc_id = data.aws_vpc.default.id + + ingress { + description = "SSH from everywhere" + from_port = 22 + to_port = 22 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] + } + + ingress { + description = "Http from everywhere" + from_port = 80 + to_port = 80 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] + } + ingress { + description = "Custom TCP" + from_port = 8081 + to_port = 8083 + protocol = "TCP" + cidr_blocks = ["0.0.0.0/0"] + } + + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] + } + + tags = merge(local.default_tags, + { + "Name" = "${local.name_prefix}-sg" + } + ) +} + +resource "aws_eip" "static_eip_my_instance_1" { + instance = aws_instance.my_instance_1.id + tags = merge(local.default_tags, + { + "Name" = "${local.name_prefix}-eip" + } + ) +} + +# Elastic Container Registry (ECR) - Create a new repository +resource "aws_ecr_repository" "app_ecr_repo" { + name = lower("${local.name_prefix}-ecr-repo") + image_tag_mutability = "MUTABLE" + tags = merge(local.default_tags, + { + "Name" = "${local.name_prefix}-ecr-repo" + } + ) +} +resource "aws_ecr_repository" "mysql_ecr_repo" { + name = lower("${local.name_prefix}-mysql-ecr-repo") + image_tag_mutability = "MUTABLE" + + tags = merge(local.default_tags, + { + "Name" = "${local.name_prefix}-mysql-ecr-repo" + } + ) +} \ No newline at end of file diff --git a/terraform/dev/instances/output.tf b/terraform/dev/instances/output.tf new file mode 100644 index 0000000..ffea506 --- /dev/null +++ b/terraform/dev/instances/output.tf @@ -0,0 +1,12 @@ +# Step 10 - Add output variables +output "eip_my_instance" { + value = aws_eip.static_eip_my_instance.public_ip +} + +output "eip_my_instance1" { + value = aws_eip.static_eip_my_instance_1.public_ip +} + +output "eip_my_instance2" { + value = aws_eip.static_eip_my_instance_2.public_ip +} \ No newline at end of file diff --git a/terraform/dev/instances/terraform.tfstate b/terraform/dev/instances/terraform.tfstate new file mode 100644 index 0000000..c166fe0 --- /dev/null +++ b/terraform/dev/instances/terraform.tfstate @@ -0,0 +1,995 @@ +{ + "version": 4, + "terraform_version": "1.9.6", + "serial": 29, + "lineage": "ca5d1e0f-4e38-d0e9-f5fe-3091027f23b0", + "outputs": { + "eip_my_instance": { + "value": "52.55.167.209", + "type": "string" + }, + "eip_my_instance1": { + "value": "3.226.21.184", + "type": "string" + }, + "eip_my_instance2": { + "value": "98.82.226.52", + "type": "string" + } + }, + "resources": [ + { + "mode": "data", + "type": "aws_ami", + "name": "latest_amazon_linux", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "architecture": "x86_64", + "arn": "arn:aws:ec2:us-east-1::image/ami-052b9fbb6949f883a", + "block_device_mappings": [ + { + "device_name": "/dev/xvda", + "ebs": { + "delete_on_termination": "true", + "encrypted": "false", + "iops": "0", + "snapshot_id": "snap-0be4171a54ec9da0b", + "throughput": "0", + "volume_size": "8", + "volume_type": "gp2" + }, + "no_device": "", + "virtual_name": "" + } + ], + "boot_mode": "", + "creation_date": "2024-09-16T18:59:41.000Z", + "deprecation_time": "2025-07-01T00:00:00.000Z", + "description": "Amazon Linux 2 AMI 2.0.20240916.0 x86_64 HVM gp2", + "ena_support": true, + "executable_users": null, + "filter": [ + { + "name": "name", + "values": [ + "amzn2-ami-hvm-*-x86_64-gp2" + ] + } + ], + "hypervisor": "xen", + "id": "ami-052b9fbb6949f883a", + "image_id": "ami-052b9fbb6949f883a", + "image_location": "amazon/amzn2-ami-hvm-2.0.20240916.0-x86_64-gp2", + "image_owner_alias": "amazon", + "image_type": "machine", + "imds_support": "", + "include_deprecated": false, + "kernel_id": "", + "most_recent": true, + "name": "amzn2-ami-hvm-2.0.20240916.0-x86_64-gp2", + "name_regex": null, + "owner_id": "137112412989", + "owners": [ + "amazon" + ], + "platform": "", + "platform_details": "Linux/UNIX", + "product_codes": [], + "public": true, + "ramdisk_id": "", + "root_device_name": "/dev/xvda", + "root_device_type": "ebs", + "root_snapshot_id": "snap-0be4171a54ec9da0b", + "sriov_net_support": "simple", + "state": "available", + "state_reason": { + "code": "UNSET", + "message": "UNSET" + }, + "tags": {}, + "timeouts": null, + "tpm_support": "", + "usage_operation": "RunInstances", + "virtualization_type": "hvm" + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "data", + "type": "aws_availability_zones", + "name": "available", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "all_availability_zones": null, + "exclude_names": null, + "exclude_zone_ids": null, + "filter": null, + "group_names": [ + "us-east-1" + ], + "id": "us-east-1", + "names": [ + "us-east-1a", + "us-east-1b", + "us-east-1c", + "us-east-1d", + "us-east-1e", + "us-east-1f" + ], + "state": "available", + "timeouts": null, + "zone_ids": [ + "use1-az1", + "use1-az2", + "use1-az4", + "use1-az6", + "use1-az3", + "use1-az5" + ] + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "data", + "type": "aws_vpc", + "name": "default", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:345771349539:vpc/vpc-0fe25bfc810e1d519", + "cidr_block": "172.31.0.0/16", + "cidr_block_associations": [ + { + "association_id": "vpc-cidr-assoc-0c06c0bce6df7ec24", + "cidr_block": "172.31.0.0/16", + "state": "associated" + } + ], + "default": true, + "dhcp_options_id": "dopt-0b6c688c87b2861c5", + "enable_dns_hostnames": true, + "enable_dns_support": true, + "enable_network_address_usage_metrics": false, + "filter": null, + "id": "vpc-0fe25bfc810e1d519", + "instance_tenancy": "default", + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "main_route_table_id": "rtb-0395b3b999ce80ba7", + "owner_id": "345771349539", + "state": null, + "tags": {}, + "timeouts": null + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "managed", + "type": "aws_ecr_repository", + "name": "my_ecr_repo", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ecr:us-east-1:345771349539:repository/assignmentdocker-dev-ecr-repo", + "encryption_configuration": [ + { + "encryption_type": "AES256", + "kms_key": "" + } + ], + "force_delete": null, + "id": "assignmentdocker-dev-ecr-repo", + "image_scanning_configuration": [ + { + "scan_on_push": false + } + ], + "image_tag_mutability": "MUTABLE", + "name": "assignmentdocker-dev-ecr-repo", + "registry_id": "345771349539", + "repository_url": "345771349539.dkr.ecr.us-east-1.amazonaws.com/assignmentdocker-dev-ecr-repo", + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-ecr-repo", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-ecr-repo", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "timeouts": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjoxMjAwMDAwMDAwMDAwfX0=" + } + ] + }, + { + "mode": "managed", + "type": "aws_ecr_repository", + "name": "mysql_ecr_repo", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ecr:us-east-1:345771349539:repository/assignmentdocker-dev-mysql-ecr-repo", + "encryption_configuration": [ + { + "encryption_type": "AES256", + "kms_key": "" + } + ], + "force_delete": null, + "id": "assignmentdocker-dev-mysql-ecr-repo", + "image_scanning_configuration": [ + { + "scan_on_push": false + } + ], + "image_tag_mutability": "MUTABLE", + "name": "assignmentdocker-dev-mysql-ecr-repo", + "registry_id": "345771349539", + "repository_url": "345771349539.dkr.ecr.us-east-1.amazonaws.com/assignmentdocker-dev-mysql-ecr-repo", + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-mysql-ecr-repo", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-mysql-ecr-repo", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "timeouts": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjoxMjAwMDAwMDAwMDAwfX0=" + } + ] + }, + { + "mode": "managed", + "type": "aws_eip", + "name": "static_eip_my_instance", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "address": null, + "allocation_id": "eipalloc-04870422c25df54d0", + "arn": "arn:aws:ec2:us-east-1:345771349539:elastic-ip/eipalloc-04870422c25df54d0", + "associate_with_private_ip": null, + "association_id": "eipassoc-005ccd31394450e11", + "carrier_ip": "", + "customer_owned_ip": "", + "customer_owned_ipv4_pool": "", + "domain": "vpc", + "id": "eipalloc-04870422c25df54d0", + "instance": "i-05d0997e82dcfdd10", + "network_border_group": "us-east-1", + "network_interface": "eni-0be62202b13a9b25b", + "private_dns": "ip-172-31-95-67.ec2.internal", + "private_ip": "172.31.95.67", + "ptr_record": "", + "public_dns": "ec2-52-55-167-209.compute-1.amazonaws.com", + "public_ip": "52.55.167.209", + "public_ipv4_pool": "amazon", + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-eip", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-eip", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "timeouts": null, + "vpc": true + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjoxODAwMDAwMDAwMDAsInJlYWQiOjkwMDAwMDAwMDAwMCwidXBkYXRlIjozMDAwMDAwMDAwMDB9fQ==", + "dependencies": [ + "aws_instance.my_instance", + "aws_key_pair.my_key", + "aws_security_group.my_sg", + "data.aws_ami.latest_amazon_linux", + "data.aws_vpc.default" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_eip", + "name": "static_eip_my_instance_1", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "address": null, + "allocation_id": "eipalloc-0247c6ccc13ab9c2a", + "arn": "arn:aws:ec2:us-east-1:345771349539:elastic-ip/eipalloc-0247c6ccc13ab9c2a", + "associate_with_private_ip": null, + "association_id": "eipassoc-0f57d597707f2a2e1", + "carrier_ip": "", + "customer_owned_ip": "", + "customer_owned_ipv4_pool": "", + "domain": "vpc", + "id": "eipalloc-0247c6ccc13ab9c2a", + "instance": "i-0f148ebd4baf910af", + "network_border_group": "us-east-1", + "network_interface": "eni-0a671d942ecf642df", + "private_dns": "ip-172-31-95-157.ec2.internal", + "private_ip": "172.31.95.157", + "ptr_record": "", + "public_dns": "ec2-3-226-21-184.compute-1.amazonaws.com", + "public_ip": "3.226.21.184", + "public_ipv4_pool": "amazon", + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-eip", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-eip", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "timeouts": null, + "vpc": true + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjoxODAwMDAwMDAwMDAsInJlYWQiOjkwMDAwMDAwMDAwMCwidXBkYXRlIjozMDAwMDAwMDAwMDB9fQ==", + "dependencies": [ + "aws_instance.my_instance_1", + "aws_key_pair.my_key", + "aws_security_group.my_sg", + "data.aws_ami.latest_amazon_linux", + "data.aws_vpc.default" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_eip", + "name": "static_eip_my_instance_2", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "address": null, + "allocation_id": "eipalloc-067a198e8fca138fa", + "arn": "arn:aws:ec2:us-east-1:345771349539:elastic-ip/eipalloc-067a198e8fca138fa", + "associate_with_private_ip": null, + "association_id": "eipassoc-054c8ee9d5fd189ec", + "carrier_ip": "", + "customer_owned_ip": "", + "customer_owned_ipv4_pool": "", + "domain": "vpc", + "id": "eipalloc-067a198e8fca138fa", + "instance": "i-08aca63cf8a3d82d9", + "network_border_group": "us-east-1", + "network_interface": "eni-09a26a9cb29e82da6", + "private_dns": "ip-172-31-88-232.ec2.internal", + "private_ip": "172.31.88.232", + "ptr_record": "", + "public_dns": "ec2-98-82-226-52.compute-1.amazonaws.com", + "public_ip": "98.82.226.52", + "public_ipv4_pool": "amazon", + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-eip", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-eip", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "timeouts": null, + "vpc": true + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjoxODAwMDAwMDAwMDAsInJlYWQiOjkwMDAwMDAwMDAwMCwidXBkYXRlIjozMDAwMDAwMDAwMDB9fQ==", + "dependencies": [ + "aws_instance.my_instance_2", + "aws_key_pair.my_key", + "aws_security_group.my_sg", + "data.aws_ami.latest_amazon_linux", + "data.aws_vpc.default" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_instance", + "name": "my_instance", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "ami": "ami-052b9fbb6949f883a", + "arn": "arn:aws:ec2:us-east-1:345771349539:instance/i-05d0997e82dcfdd10", + "associate_public_ip_address": true, + "availability_zone": "us-east-1b", + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open", + "capacity_reservation_target": [] + } + ], + "cpu_core_count": 1, + "cpu_options": [ + { + "amd_sev_snp": "", + "core_count": 1, + "threads_per_core": 1 + } + ], + "cpu_threads_per_core": 1, + "credit_specification": [ + { + "cpu_credits": "standard" + } + ], + "disable_api_stop": false, + "disable_api_termination": false, + "ebs_block_device": [], + "ebs_optimized": false, + "enclave_options": [ + { + "enabled": false + } + ], + "ephemeral_block_device": [], + "get_password_data": false, + "hibernation": false, + "host_id": "", + "host_resource_group_arn": null, + "iam_instance_profile": "", + "id": "i-05d0997e82dcfdd10", + "instance_initiated_shutdown_behavior": "stop", + "instance_lifecycle": "", + "instance_market_options": [], + "instance_state": "running", + "instance_type": "t2.micro", + "ipv6_address_count": 0, + "ipv6_addresses": [], + "key_name": "assignmentdocker-dev", + "launch_template": [], + "maintenance_options": [ + { + "auto_recovery": "default" + } + ], + "metadata_options": [ + { + "http_endpoint": "enabled", + "http_protocol_ipv6": "disabled", + "http_put_response_hop_limit": 1, + "http_tokens": "optional", + "instance_metadata_tags": "disabled" + } + ], + "monitoring": false, + "network_interface": [], + "outpost_arn": "", + "password_data": "", + "placement_group": "", + "placement_partition_number": 0, + "primary_network_interface_id": "eni-0be62202b13a9b25b", + "private_dns": "ip-172-31-95-67.ec2.internal", + "private_dns_name_options": [ + { + "enable_resource_name_dns_a_record": false, + "enable_resource_name_dns_aaaa_record": false, + "hostname_type": "ip-name" + } + ], + "private_ip": "172.31.95.67", + "public_dns": "ec2-3-83-14-3.compute-1.amazonaws.com", + "public_ip": "3.83.14.3", + "root_block_device": [ + { + "delete_on_termination": true, + "device_name": "/dev/xvda", + "encrypted": false, + "iops": 100, + "kms_key_id": "", + "tags": {}, + "tags_all": {}, + "throughput": 0, + "volume_id": "vol-087897d76ba62691b", + "volume_size": 8, + "volume_type": "gp2" + } + ], + "secondary_private_ips": [], + "security_groups": [ + "allow_ssh" + ], + "source_dest_check": true, + "spot_instance_request_id": "", + "subnet_id": "subnet-04ce7404327e72f5d", + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-my-instance-Linux", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-my-instance-Linux", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tenancy": "default", + "timeouts": null, + "user_data": null, + "user_data_base64": null, + "user_data_replace_on_change": false, + "volume_tags": null, + "vpc_security_group_ids": [ + "sg-01c6c4234a92ab72e" + ] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwicmVhZCI6OTAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "aws_key_pair.my_key", + "aws_security_group.my_sg", + "data.aws_ami.latest_amazon_linux", + "data.aws_vpc.default" + ], + "create_before_destroy": true + } + ] + }, + { + "mode": "managed", + "type": "aws_instance", + "name": "my_instance_1", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "ami": "ami-052b9fbb6949f883a", + "arn": "arn:aws:ec2:us-east-1:345771349539:instance/i-0f148ebd4baf910af", + "associate_public_ip_address": true, + "availability_zone": "us-east-1b", + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open", + "capacity_reservation_target": [] + } + ], + "cpu_core_count": 1, + "cpu_options": [ + { + "amd_sev_snp": "", + "core_count": 1, + "threads_per_core": 1 + } + ], + "cpu_threads_per_core": 1, + "credit_specification": [ + { + "cpu_credits": "standard" + } + ], + "disable_api_stop": false, + "disable_api_termination": false, + "ebs_block_device": [], + "ebs_optimized": false, + "enclave_options": [ + { + "enabled": false + } + ], + "ephemeral_block_device": [], + "get_password_data": false, + "hibernation": false, + "host_id": "", + "host_resource_group_arn": null, + "iam_instance_profile": "", + "id": "i-0f148ebd4baf910af", + "instance_initiated_shutdown_behavior": "stop", + "instance_lifecycle": "", + "instance_market_options": [], + "instance_state": "running", + "instance_type": "t2.micro", + "ipv6_address_count": 0, + "ipv6_addresses": [], + "key_name": "assignmentdocker-dev", + "launch_template": [], + "maintenance_options": [ + { + "auto_recovery": "default" + } + ], + "metadata_options": [ + { + "http_endpoint": "enabled", + "http_protocol_ipv6": "disabled", + "http_put_response_hop_limit": 1, + "http_tokens": "optional", + "instance_metadata_tags": "disabled" + } + ], + "monitoring": false, + "network_interface": [], + "outpost_arn": "", + "password_data": "", + "placement_group": "", + "placement_partition_number": 0, + "primary_network_interface_id": "eni-0a671d942ecf642df", + "private_dns": "ip-172-31-95-157.ec2.internal", + "private_dns_name_options": [ + { + "enable_resource_name_dns_a_record": false, + "enable_resource_name_dns_aaaa_record": false, + "hostname_type": "ip-name" + } + ], + "private_ip": "172.31.95.157", + "public_dns": "ec2-34-239-120-155.compute-1.amazonaws.com", + "public_ip": "34.239.120.155", + "root_block_device": [ + { + "delete_on_termination": true, + "device_name": "/dev/xvda", + "encrypted": false, + "iops": 100, + "kms_key_id": "", + "tags": {}, + "tags_all": {}, + "throughput": 0, + "volume_id": "vol-0b6db89560a63d62a", + "volume_size": 8, + "volume_type": "gp2" + } + ], + "secondary_private_ips": [], + "security_groups": [ + "allow_ssh" + ], + "source_dest_check": true, + "spot_instance_request_id": "", + "subnet_id": "subnet-04ce7404327e72f5d", + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-my-instance-1", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-my-instance-1", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tenancy": "default", + "timeouts": null, + "user_data": null, + "user_data_base64": null, + "user_data_replace_on_change": false, + "volume_tags": null, + "vpc_security_group_ids": [ + "sg-01c6c4234a92ab72e" + ] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwicmVhZCI6OTAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "aws_key_pair.my_key", + "aws_security_group.my_sg", + "data.aws_ami.latest_amazon_linux", + "data.aws_vpc.default" + ], + "create_before_destroy": true + } + ] + }, + { + "mode": "managed", + "type": "aws_instance", + "name": "my_instance_2", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "ami": "ami-052b9fbb6949f883a", + "arn": "arn:aws:ec2:us-east-1:345771349539:instance/i-08aca63cf8a3d82d9", + "associate_public_ip_address": true, + "availability_zone": "us-east-1b", + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open", + "capacity_reservation_target": [] + } + ], + "cpu_core_count": 1, + "cpu_options": [ + { + "amd_sev_snp": "", + "core_count": 1, + "threads_per_core": 1 + } + ], + "cpu_threads_per_core": 1, + "credit_specification": [ + { + "cpu_credits": "standard" + } + ], + "disable_api_stop": false, + "disable_api_termination": false, + "ebs_block_device": [], + "ebs_optimized": false, + "enclave_options": [ + { + "enabled": false + } + ], + "ephemeral_block_device": [], + "get_password_data": false, + "hibernation": false, + "host_id": "", + "host_resource_group_arn": null, + "iam_instance_profile": "", + "id": "i-08aca63cf8a3d82d9", + "instance_initiated_shutdown_behavior": "stop", + "instance_lifecycle": "", + "instance_market_options": [], + "instance_state": "running", + "instance_type": "t2.micro", + "ipv6_address_count": 0, + "ipv6_addresses": [], + "key_name": "assignmentdocker-dev", + "launch_template": [], + "maintenance_options": [ + { + "auto_recovery": "default" + } + ], + "metadata_options": [ + { + "http_endpoint": "enabled", + "http_protocol_ipv6": "disabled", + "http_put_response_hop_limit": 1, + "http_tokens": "optional", + "instance_metadata_tags": "disabled" + } + ], + "monitoring": false, + "network_interface": [], + "outpost_arn": "", + "password_data": "", + "placement_group": "", + "placement_partition_number": 0, + "primary_network_interface_id": "eni-09a26a9cb29e82da6", + "private_dns": "ip-172-31-88-232.ec2.internal", + "private_dns_name_options": [ + { + "enable_resource_name_dns_a_record": false, + "enable_resource_name_dns_aaaa_record": false, + "hostname_type": "ip-name" + } + ], + "private_ip": "172.31.88.232", + "public_dns": "ec2-18-205-190-145.compute-1.amazonaws.com", + "public_ip": "18.205.190.145", + "root_block_device": [ + { + "delete_on_termination": true, + "device_name": "/dev/xvda", + "encrypted": false, + "iops": 100, + "kms_key_id": "", + "tags": {}, + "tags_all": {}, + "throughput": 0, + "volume_id": "vol-0f2e8021d32f612f7", + "volume_size": 8, + "volume_type": "gp2" + } + ], + "secondary_private_ips": [], + "security_groups": [ + "allow_ssh" + ], + "source_dest_check": true, + "spot_instance_request_id": "", + "subnet_id": "subnet-04ce7404327e72f5d", + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-my-instance-2", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-my-instance-2", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tenancy": "default", + "timeouts": null, + "user_data": null, + "user_data_base64": null, + "user_data_replace_on_change": false, + "volume_tags": null, + "vpc_security_group_ids": [ + "sg-01c6c4234a92ab72e" + ] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwicmVhZCI6OTAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "aws_key_pair.my_key", + "aws_security_group.my_sg", + "data.aws_ami.latest_amazon_linux", + "data.aws_vpc.default" + ], + "create_before_destroy": true + } + ] + }, + { + "mode": "managed", + "type": "aws_key_pair", + "name": "my_key", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:345771349539:key-pair/assignmentdocker-dev", + "fingerprint": "31:0d:58:d7:35:66:d2:1e:e0:32:50:5e:72:4d:39:b3", + "id": "assignmentdocker-dev", + "key_name": "assignmentdocker-dev", + "key_name_prefix": "", + "key_pair_id": "key-0871a922ae48b8d60", + "key_type": "rsa", + "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDOlcMjUwyJX+BQZ929PjHtWoJk/5X9EKBijHtnSsjzRDkdgtk4jY3qoQnyWgqwoYTjyyxcQJpN5WKYoZCKCNiAdjT3MpEmZoaqmbFHAEO67Ij71BBEmNICC0PBmFEVQNIy82iy0ljd1z53FFKZvLUAjrsPw9EZUhWujXNIKEuIkPY3ZSdiyaHoIS8H2IDKfGUPWoq1rwt3+5Up8CPM5y8zC7OEfXidK6k0Pagxf0Z4UmE4WjJc5n8UNUc3DVuTT0dqqhfntc/Ft8W+oYaIgJeKift6QxzN4Y8FAG3SmlSEqy1pCklFOOCtgXGVLc3M58stYGISEtOtL1YcEHowe17HvEF3gijiw9g1Tkuthc4JcJ29XqRL5NtBDmhUPWbmAB11Hmtp3y7Q4RUGQvQAOstBT4ZNhWTjKYisW1BMesr941FXslhPgo8k8GVA4wvs2Qt279HZbx709W4qdL6X3Bj++3WlCzCLAQUbs3SnhKckp3fqXNKrxfUqrIXXrbnjSBM= ec2-user@ip-172-31-20-209.ec2.internal", + "tags": {}, + "tags_all": {} + }, + "sensitive_attributes": [], + "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", + "create_before_destroy": true + } + ] + }, + { + "mode": "managed", + "type": "aws_security_group", + "name": "my_sg", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:345771349539:security-group/sg-01c6c4234a92ab72e", + "description": "Allow SSH inbound traffic", + "egress": [ + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "", + "from_port": 0, + "ipv6_cidr_blocks": [ + "::/0" + ], + "prefix_list_ids": [], + "protocol": "-1", + "security_groups": [], + "self": false, + "to_port": 0 + } + ], + "id": "sg-01c6c4234a92ab72e", + "ingress": [ + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "SSH from everywhere", + "from_port": 22, + "ipv6_cidr_blocks": [ + "::/0" + ], + "prefix_list_ids": [], + "protocol": "tcp", + "security_groups": [], + "self": false, + "to_port": 22 + } + ], + "name": "allow_ssh", + "name_prefix": "", + "owner_id": "345771349539", + "revoke_rules_on_delete": false, + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-sg", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-sg", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "timeouts": null, + "vpc_id": "vpc-0fe25bfc810e1d519" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6OTAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIxIn0=", + "dependencies": [ + "data.aws_vpc.default" + ], + "create_before_destroy": true + } + ] + } + ], + "check_results": null +} diff --git a/terraform/dev/instances/terraform.tfstate.backup b/terraform/dev/instances/terraform.tfstate.backup new file mode 100644 index 0000000..e76bcce --- /dev/null +++ b/terraform/dev/instances/terraform.tfstate.backup @@ -0,0 +1,947 @@ +{ + "version": 4, + "terraform_version": "1.9.6", + "serial": 18, + "lineage": "ca5d1e0f-4e38-d0e9-f5fe-3091027f23b0", + "outputs": { + "eip_my_instance": { + "value": "52.55.167.209", + "type": "string" + }, + "eip_my_instance1": { + "value": "3.226.21.184", + "type": "string" + }, + "eip_my_instance2": { + "value": "98.82.226.52", + "type": "string" + } + }, + "resources": [ + { + "mode": "data", + "type": "aws_ami", + "name": "latest_amazon_linux", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "architecture": "x86_64", + "arn": "arn:aws:ec2:us-east-1::image/ami-052b9fbb6949f883a", + "block_device_mappings": [ + { + "device_name": "/dev/xvda", + "ebs": { + "delete_on_termination": "true", + "encrypted": "false", + "iops": "0", + "snapshot_id": "snap-0be4171a54ec9da0b", + "throughput": "0", + "volume_size": "8", + "volume_type": "gp2" + }, + "no_device": "", + "virtual_name": "" + } + ], + "boot_mode": "", + "creation_date": "2024-09-16T18:59:41.000Z", + "deprecation_time": "2025-07-01T00:00:00.000Z", + "description": "Amazon Linux 2 AMI 2.0.20240916.0 x86_64 HVM gp2", + "ena_support": true, + "executable_users": null, + "filter": [ + { + "name": "name", + "values": [ + "amzn2-ami-hvm-*-x86_64-gp2" + ] + } + ], + "hypervisor": "xen", + "id": "ami-052b9fbb6949f883a", + "image_id": "ami-052b9fbb6949f883a", + "image_location": "amazon/amzn2-ami-hvm-2.0.20240916.0-x86_64-gp2", + "image_owner_alias": "amazon", + "image_type": "machine", + "imds_support": "", + "include_deprecated": false, + "kernel_id": "", + "most_recent": true, + "name": "amzn2-ami-hvm-2.0.20240916.0-x86_64-gp2", + "name_regex": null, + "owner_id": "137112412989", + "owners": [ + "amazon" + ], + "platform": "", + "platform_details": "Linux/UNIX", + "product_codes": [], + "public": true, + "ramdisk_id": "", + "root_device_name": "/dev/xvda", + "root_device_type": "ebs", + "root_snapshot_id": "snap-0be4171a54ec9da0b", + "sriov_net_support": "simple", + "state": "available", + "state_reason": { + "code": "UNSET", + "message": "UNSET" + }, + "tags": {}, + "timeouts": null, + "tpm_support": "", + "usage_operation": "RunInstances", + "virtualization_type": "hvm" + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "data", + "type": "aws_availability_zones", + "name": "available", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "all_availability_zones": null, + "exclude_names": null, + "exclude_zone_ids": null, + "filter": null, + "group_names": [ + "us-east-1" + ], + "id": "us-east-1", + "names": [ + "us-east-1a", + "us-east-1b", + "us-east-1c", + "us-east-1d", + "us-east-1e", + "us-east-1f" + ], + "state": "available", + "timeouts": null, + "zone_ids": [ + "use1-az1", + "use1-az2", + "use1-az4", + "use1-az6", + "use1-az3", + "use1-az5" + ] + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "data", + "type": "aws_vpc", + "name": "default", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:345771349539:vpc/vpc-0fe25bfc810e1d519", + "cidr_block": "172.31.0.0/16", + "cidr_block_associations": [ + { + "association_id": "vpc-cidr-assoc-0c06c0bce6df7ec24", + "cidr_block": "172.31.0.0/16", + "state": "associated" + } + ], + "default": true, + "dhcp_options_id": "dopt-0b6c688c87b2861c5", + "enable_dns_hostnames": true, + "enable_dns_support": true, + "enable_network_address_usage_metrics": false, + "filter": null, + "id": "vpc-0fe25bfc810e1d519", + "instance_tenancy": "default", + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "main_route_table_id": "rtb-0395b3b999ce80ba7", + "owner_id": "345771349539", + "state": null, + "tags": {}, + "timeouts": null + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "managed", + "type": "aws_ecr_repository", + "name": "my_ecr_repo", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ecr:us-east-1:345771349539:repository/assignmentdocker-dev-ecr-repo", + "encryption_configuration": [ + { + "encryption_type": "AES256", + "kms_key": "" + } + ], + "force_delete": null, + "id": "assignmentdocker-dev-ecr-repo", + "image_scanning_configuration": [ + { + "scan_on_push": false + } + ], + "image_tag_mutability": "MUTABLE", + "name": "assignmentdocker-dev-ecr-repo", + "registry_id": "345771349539", + "repository_url": "345771349539.dkr.ecr.us-east-1.amazonaws.com/assignmentdocker-dev-ecr-repo", + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-ecr-repo", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-ecr-repo", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "timeouts": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjoxMjAwMDAwMDAwMDAwfX0=" + } + ] + }, + { + "mode": "managed", + "type": "aws_eip", + "name": "static_eip_my_instance", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "address": null, + "allocation_id": "eipalloc-04870422c25df54d0", + "arn": "arn:aws:ec2:us-east-1:345771349539:elastic-ip/eipalloc-04870422c25df54d0", + "associate_with_private_ip": null, + "association_id": "eipassoc-03c694d927363814f", + "carrier_ip": "", + "customer_owned_ip": "", + "customer_owned_ipv4_pool": "", + "domain": "vpc", + "id": "eipalloc-04870422c25df54d0", + "instance": "i-08e6eb9f316248fb6", + "network_border_group": "us-east-1", + "network_interface": "eni-0d1a87fb44dbd5295", + "private_dns": "ip-172-31-93-39.ec2.internal", + "private_ip": "172.31.93.39", + "ptr_record": "", + "public_dns": "ec2-52-55-167-209.compute-1.amazonaws.com", + "public_ip": "52.55.167.209", + "public_ipv4_pool": "amazon", + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-eip", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-eip", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "timeouts": null, + "vpc": true + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjoxODAwMDAwMDAwMDAsInJlYWQiOjkwMDAwMDAwMDAwMCwidXBkYXRlIjozMDAwMDAwMDAwMDB9fQ==", + "dependencies": [ + "aws_instance.my_instance", + "aws_key_pair.my_key", + "aws_security_group.my_sg", + "data.aws_ami.latest_amazon_linux", + "data.aws_vpc.default" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_eip", + "name": "static_eip_my_instance_1", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "address": null, + "allocation_id": "eipalloc-0247c6ccc13ab9c2a", + "arn": "arn:aws:ec2:us-east-1:345771349539:elastic-ip/eipalloc-0247c6ccc13ab9c2a", + "associate_with_private_ip": null, + "association_id": "eipassoc-060efd4e02b834666", + "carrier_ip": "", + "customer_owned_ip": "", + "customer_owned_ipv4_pool": "", + "domain": "vpc", + "id": "eipalloc-0247c6ccc13ab9c2a", + "instance": "i-019ca8f09e4db89c8", + "network_border_group": "us-east-1", + "network_interface": "eni-0961d3d5a2cab1f25", + "private_dns": "ip-172-31-88-43.ec2.internal", + "private_ip": "172.31.88.43", + "ptr_record": "", + "public_dns": "ec2-3-226-21-184.compute-1.amazonaws.com", + "public_ip": "3.226.21.184", + "public_ipv4_pool": "amazon", + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-eip", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-eip", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "timeouts": null, + "vpc": true + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjoxODAwMDAwMDAwMDAsInJlYWQiOjkwMDAwMDAwMDAwMCwidXBkYXRlIjozMDAwMDAwMDAwMDB9fQ==", + "dependencies": [ + "aws_instance.my_instance_1", + "aws_key_pair.my_key", + "aws_security_group.my_sg", + "data.aws_ami.latest_amazon_linux", + "data.aws_vpc.default" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_eip", + "name": "static_eip_my_instance_2", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "address": null, + "allocation_id": "eipalloc-067a198e8fca138fa", + "arn": "arn:aws:ec2:us-east-1:345771349539:elastic-ip/eipalloc-067a198e8fca138fa", + "associate_with_private_ip": null, + "association_id": "eipassoc-0db0ff3d55e3b1dd3", + "carrier_ip": "", + "customer_owned_ip": "", + "customer_owned_ipv4_pool": "", + "domain": "vpc", + "id": "eipalloc-067a198e8fca138fa", + "instance": "i-0612ed9124246fb01", + "network_border_group": "us-east-1", + "network_interface": "eni-0be4318e5cb4eb111", + "private_dns": "ip-172-31-82-2.ec2.internal", + "private_ip": "172.31.82.2", + "ptr_record": "", + "public_dns": "ec2-98-82-226-52.compute-1.amazonaws.com", + "public_ip": "98.82.226.52", + "public_ipv4_pool": "amazon", + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-eip", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-eip", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "timeouts": null, + "vpc": true + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjoxODAwMDAwMDAwMDAsInJlYWQiOjkwMDAwMDAwMDAwMCwidXBkYXRlIjozMDAwMDAwMDAwMDB9fQ==", + "dependencies": [ + "aws_instance.my_instance_2", + "aws_key_pair.my_key", + "aws_security_group.my_sg", + "data.aws_ami.latest_amazon_linux", + "data.aws_vpc.default" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_instance", + "name": "my_instance", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "ami": "ami-052b9fbb6949f883a", + "arn": "arn:aws:ec2:us-east-1:345771349539:instance/i-08e6eb9f316248fb6", + "associate_public_ip_address": true, + "availability_zone": "us-east-1b", + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open", + "capacity_reservation_target": [] + } + ], + "cpu_core_count": 1, + "cpu_options": [ + { + "amd_sev_snp": "", + "core_count": 1, + "threads_per_core": 1 + } + ], + "cpu_threads_per_core": 1, + "credit_specification": [ + { + "cpu_credits": "standard" + } + ], + "disable_api_stop": false, + "disable_api_termination": false, + "ebs_block_device": [], + "ebs_optimized": false, + "enclave_options": [ + { + "enabled": false + } + ], + "ephemeral_block_device": [], + "get_password_data": false, + "hibernation": false, + "host_id": "", + "host_resource_group_arn": null, + "iam_instance_profile": "", + "id": "i-08e6eb9f316248fb6", + "instance_initiated_shutdown_behavior": "stop", + "instance_lifecycle": "", + "instance_market_options": [], + "instance_state": "running", + "instance_type": "t2.micro", + "ipv6_address_count": 0, + "ipv6_addresses": [], + "key_name": "assignmentdocker-dev", + "launch_template": [], + "maintenance_options": [ + { + "auto_recovery": "default" + } + ], + "metadata_options": [ + { + "http_endpoint": "enabled", + "http_protocol_ipv6": "disabled", + "http_put_response_hop_limit": 1, + "http_tokens": "optional", + "instance_metadata_tags": "disabled" + } + ], + "monitoring": false, + "network_interface": [], + "outpost_arn": "", + "password_data": "", + "placement_group": "", + "placement_partition_number": 0, + "primary_network_interface_id": "eni-0d1a87fb44dbd5295", + "private_dns": "ip-172-31-93-39.ec2.internal", + "private_dns_name_options": [ + { + "enable_resource_name_dns_a_record": false, + "enable_resource_name_dns_aaaa_record": false, + "hostname_type": "ip-name" + } + ], + "private_ip": "172.31.93.39", + "public_dns": "ec2-54-91-130-75.compute-1.amazonaws.com", + "public_ip": "54.91.130.75", + "root_block_device": [ + { + "delete_on_termination": true, + "device_name": "/dev/xvda", + "encrypted": false, + "iops": 100, + "kms_key_id": "", + "tags": {}, + "tags_all": {}, + "throughput": 0, + "volume_id": "vol-026e2132d0a4ec271", + "volume_size": 8, + "volume_type": "gp2" + } + ], + "secondary_private_ips": [], + "security_groups": [ + "allow_ssh" + ], + "source_dest_check": true, + "spot_instance_request_id": "", + "subnet_id": "subnet-04ce7404327e72f5d", + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-my-instance-Linux", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-my-instance-Linux", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tenancy": "default", + "timeouts": null, + "user_data": null, + "user_data_base64": null, + "user_data_replace_on_change": false, + "volume_tags": null, + "vpc_security_group_ids": [ + "sg-01c6c4234a92ab72e" + ] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwicmVhZCI6OTAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "aws_key_pair.my_key", + "aws_security_group.my_sg", + "data.aws_ami.latest_amazon_linux", + "data.aws_vpc.default" + ], + "create_before_destroy": true + } + ] + }, + { + "mode": "managed", + "type": "aws_instance", + "name": "my_instance_1", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "ami": "ami-052b9fbb6949f883a", + "arn": "arn:aws:ec2:us-east-1:345771349539:instance/i-019ca8f09e4db89c8", + "associate_public_ip_address": true, + "availability_zone": "us-east-1b", + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open", + "capacity_reservation_target": [] + } + ], + "cpu_core_count": 1, + "cpu_options": [ + { + "amd_sev_snp": "", + "core_count": 1, + "threads_per_core": 1 + } + ], + "cpu_threads_per_core": 1, + "credit_specification": [ + { + "cpu_credits": "standard" + } + ], + "disable_api_stop": false, + "disable_api_termination": false, + "ebs_block_device": [], + "ebs_optimized": false, + "enclave_options": [ + { + "enabled": false + } + ], + "ephemeral_block_device": [], + "get_password_data": false, + "hibernation": false, + "host_id": "", + "host_resource_group_arn": null, + "iam_instance_profile": "", + "id": "i-019ca8f09e4db89c8", + "instance_initiated_shutdown_behavior": "stop", + "instance_lifecycle": "", + "instance_market_options": [], + "instance_state": "running", + "instance_type": "t2.micro", + "ipv6_address_count": 0, + "ipv6_addresses": [], + "key_name": "assignmentdocker-dev", + "launch_template": [], + "maintenance_options": [ + { + "auto_recovery": "default" + } + ], + "metadata_options": [ + { + "http_endpoint": "enabled", + "http_protocol_ipv6": "disabled", + "http_put_response_hop_limit": 1, + "http_tokens": "optional", + "instance_metadata_tags": "disabled" + } + ], + "monitoring": false, + "network_interface": [], + "outpost_arn": "", + "password_data": "", + "placement_group": "", + "placement_partition_number": 0, + "primary_network_interface_id": "eni-0961d3d5a2cab1f25", + "private_dns": "ip-172-31-88-43.ec2.internal", + "private_dns_name_options": [ + { + "enable_resource_name_dns_a_record": false, + "enable_resource_name_dns_aaaa_record": false, + "hostname_type": "ip-name" + } + ], + "private_ip": "172.31.88.43", + "public_dns": "ec2-3-90-53-79.compute-1.amazonaws.com", + "public_ip": "3.90.53.79", + "root_block_device": [ + { + "delete_on_termination": true, + "device_name": "/dev/xvda", + "encrypted": false, + "iops": 100, + "kms_key_id": "", + "tags": {}, + "tags_all": {}, + "throughput": 0, + "volume_id": "vol-098a5cab91b1d0e8a", + "volume_size": 8, + "volume_type": "gp2" + } + ], + "secondary_private_ips": [], + "security_groups": [ + "allow_ssh" + ], + "source_dest_check": true, + "spot_instance_request_id": "", + "subnet_id": "subnet-04ce7404327e72f5d", + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-my-instance-1", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-my-instance-1", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tenancy": "default", + "timeouts": null, + "user_data": null, + "user_data_base64": null, + "user_data_replace_on_change": false, + "volume_tags": null, + "vpc_security_group_ids": [ + "sg-01c6c4234a92ab72e" + ] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwicmVhZCI6OTAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "aws_key_pair.my_key", + "aws_security_group.my_sg", + "data.aws_ami.latest_amazon_linux", + "data.aws_vpc.default" + ], + "create_before_destroy": true + } + ] + }, + { + "mode": "managed", + "type": "aws_instance", + "name": "my_instance_2", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "ami": "ami-052b9fbb6949f883a", + "arn": "arn:aws:ec2:us-east-1:345771349539:instance/i-0612ed9124246fb01", + "associate_public_ip_address": true, + "availability_zone": "us-east-1b", + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open", + "capacity_reservation_target": [] + } + ], + "cpu_core_count": 1, + "cpu_options": [ + { + "amd_sev_snp": "", + "core_count": 1, + "threads_per_core": 1 + } + ], + "cpu_threads_per_core": 1, + "credit_specification": [ + { + "cpu_credits": "standard" + } + ], + "disable_api_stop": false, + "disable_api_termination": false, + "ebs_block_device": [], + "ebs_optimized": false, + "enclave_options": [ + { + "enabled": false + } + ], + "ephemeral_block_device": [], + "get_password_data": false, + "hibernation": false, + "host_id": "", + "host_resource_group_arn": null, + "iam_instance_profile": "", + "id": "i-0612ed9124246fb01", + "instance_initiated_shutdown_behavior": "stop", + "instance_lifecycle": "", + "instance_market_options": [], + "instance_state": "running", + "instance_type": "t2.micro", + "ipv6_address_count": 0, + "ipv6_addresses": [], + "key_name": "assignmentdocker-dev", + "launch_template": [], + "maintenance_options": [ + { + "auto_recovery": "default" + } + ], + "metadata_options": [ + { + "http_endpoint": "enabled", + "http_protocol_ipv6": "disabled", + "http_put_response_hop_limit": 1, + "http_tokens": "optional", + "instance_metadata_tags": "disabled" + } + ], + "monitoring": false, + "network_interface": [], + "outpost_arn": "", + "password_data": "", + "placement_group": "", + "placement_partition_number": 0, + "primary_network_interface_id": "eni-0be4318e5cb4eb111", + "private_dns": "ip-172-31-82-2.ec2.internal", + "private_dns_name_options": [ + { + "enable_resource_name_dns_a_record": false, + "enable_resource_name_dns_aaaa_record": false, + "hostname_type": "ip-name" + } + ], + "private_ip": "172.31.82.2", + "public_dns": "ec2-3-83-140-17.compute-1.amazonaws.com", + "public_ip": "3.83.140.17", + "root_block_device": [ + { + "delete_on_termination": true, + "device_name": "/dev/xvda", + "encrypted": false, + "iops": 100, + "kms_key_id": "", + "tags": {}, + "tags_all": {}, + "throughput": 0, + "volume_id": "vol-05467daac4c9fae73", + "volume_size": 8, + "volume_type": "gp2" + } + ], + "secondary_private_ips": [], + "security_groups": [ + "allow_ssh" + ], + "source_dest_check": true, + "spot_instance_request_id": "", + "subnet_id": "subnet-04ce7404327e72f5d", + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-my-instance-2", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-my-instance-2", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tenancy": "default", + "timeouts": null, + "user_data": null, + "user_data_base64": null, + "user_data_replace_on_change": false, + "volume_tags": null, + "vpc_security_group_ids": [ + "sg-01c6c4234a92ab72e" + ] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwicmVhZCI6OTAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "aws_key_pair.my_key", + "aws_security_group.my_sg", + "data.aws_ami.latest_amazon_linux", + "data.aws_vpc.default" + ], + "create_before_destroy": true + } + ] + }, + { + "mode": "managed", + "type": "aws_key_pair", + "name": "my_key", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:345771349539:key-pair/assignmentdocker-dev", + "fingerprint": "31:0d:58:d7:35:66:d2:1e:e0:32:50:5e:72:4d:39:b3", + "id": "assignmentdocker-dev", + "key_name": "assignmentdocker-dev", + "key_name_prefix": "", + "key_pair_id": "key-0871a922ae48b8d60", + "key_type": "rsa", + "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDOlcMjUwyJX+BQZ929PjHtWoJk/5X9EKBijHtnSsjzRDkdgtk4jY3qoQnyWgqwoYTjyyxcQJpN5WKYoZCKCNiAdjT3MpEmZoaqmbFHAEO67Ij71BBEmNICC0PBmFEVQNIy82iy0ljd1z53FFKZvLUAjrsPw9EZUhWujXNIKEuIkPY3ZSdiyaHoIS8H2IDKfGUPWoq1rwt3+5Up8CPM5y8zC7OEfXidK6k0Pagxf0Z4UmE4WjJc5n8UNUc3DVuTT0dqqhfntc/Ft8W+oYaIgJeKift6QxzN4Y8FAG3SmlSEqy1pCklFOOCtgXGVLc3M58stYGISEtOtL1YcEHowe17HvEF3gijiw9g1Tkuthc4JcJ29XqRL5NtBDmhUPWbmAB11Hmtp3y7Q4RUGQvQAOstBT4ZNhWTjKYisW1BMesr941FXslhPgo8k8GVA4wvs2Qt279HZbx709W4qdL6X3Bj++3WlCzCLAQUbs3SnhKckp3fqXNKrxfUqrIXXrbnjSBM= ec2-user@ip-172-31-20-209.ec2.internal", + "tags": {}, + "tags_all": {} + }, + "sensitive_attributes": [], + "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", + "create_before_destroy": true + } + ] + }, + { + "mode": "managed", + "type": "aws_security_group", + "name": "my_sg", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:345771349539:security-group/sg-01c6c4234a92ab72e", + "description": "Allow SSH inbound traffic", + "egress": [ + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "", + "from_port": 0, + "ipv6_cidr_blocks": [ + "::/0" + ], + "prefix_list_ids": [], + "protocol": "-1", + "security_groups": [], + "self": false, + "to_port": 0 + } + ], + "id": "sg-01c6c4234a92ab72e", + "ingress": [ + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "SSH from everywhere", + "from_port": 22, + "ipv6_cidr_blocks": [ + "::/0" + ], + "prefix_list_ids": [], + "protocol": "tcp", + "security_groups": [], + "self": false, + "to_port": 22 + } + ], + "name": "allow_ssh", + "name_prefix": "", + "owner_id": "345771349539", + "revoke_rules_on_delete": false, + "tags": { + "App": "Web", + "Name": "assignmentdocker-dev-sg", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "tags_all": { + "App": "Web", + "Name": "assignmentdocker-dev-sg", + "Owner": "DockerAssignment", + "Project": "assignment", + "env": "dev" + }, + "timeouts": null, + "vpc_id": "vpc-0fe25bfc810e1d519" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6OTAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIxIn0=", + "dependencies": [ + "data.aws_vpc.default" + ], + "create_before_destroy": true + } + ] + } + ], + "check_results": null +} diff --git a/terraform/dev/instances/variables.tf b/terraform/dev/instances/variables.tf new file mode 100644 index 0000000..f25e07a --- /dev/null +++ b/terraform/dev/instances/variables.tf @@ -0,0 +1,22 @@ +# Instance type +variable "instance_type" { + default = { + "prod" = "t3.medium" + "test" = "t3.micro" + "staging" = "t2.micro" + "dev" = "t2.micro" + } + description = "Type of the instance" + type = map(string) +} + +# Variable to signal the current environment +variable "env" { + default = "dev" + type = string + description = "Deployment Environment" +} + + + + diff --git a/terraform/modules/globalvars/output.tf b/terraform/modules/globalvars/output.tf new file mode 100644 index 0000000..3153281 --- /dev/null +++ b/terraform/modules/globalvars/output.tf @@ -0,0 +1,13 @@ +# Default tags +output "default_tags" { + value = { + "Owner" = "DockerAssignment" + "App" = "Web" + "Project" = "assignment" + } +} + +# Prefix to identify resources +output "prefix" { + value = "assignmentdocker" +} \ No newline at end of file