diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..85346e9 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,50 @@ +name: Deploy to Amazon ECR + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + name: Build and Push Docker Images + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + with: + registry: 'aws-account-id.dkr.ecr.us-east-1.amazonaws.com' + region: 'us-east-1' + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }} + AWS_REGION: us-east-1 + + - name: Build and Push Application Docker Image to Amazon ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: application + IMAGE_TAG: v1.0 + run: | + cd app + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + + - name: Build and Push Database Docker Image to Amazon ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: database + IMAGE_TAG: v1.0 + run: | + cd db + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG diff --git a/app/app.py b/app/app.py index 34356b0..66964d9 100644 --- a/app/app.py +++ b/app/app.py @@ -30,4 +30,4 @@ def index() -> str: if __name__ == '__main__': - app.run(host='0.0.0.0') + app.run(host='0.0.0.0', port=5000, debug=True) diff --git a/db/Dockerfile b/db/Dockerfile new file mode 100644 index 0000000..91f42b2 --- /dev/null +++ b/db/Dockerfile @@ -0,0 +1,8 @@ +# Use an official MySQL runtime as a parent image +FROM mysql:latest + +# Set the working directory to /app +COPY ./init.sql /tmp + +# Copy the SQL script to create the database and table into the container +CMD [ "mysqld", "--init-file=/tmp/init.sql" ] \ No newline at end of file diff --git a/terraform/config.tf b/terraform/config.tf new file mode 100644 index 0000000..175c488 --- /dev/null +++ b/terraform/config.tf @@ -0,0 +1,4 @@ +//Terraform deployment codes +provider "aws" { + region = "us-east-1" +} diff --git a/terraform/docker b/terraform/docker new file mode 100644 index 0000000..1d71f51 --- /dev/null +++ b/terraform/docker @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAo/RNx83nVpV4o+EF2ESg5MGE/40PUyKg7Z045CZOn3+kXfYO +XhPiLtWZImz9SuioJIdqOBK6XGFd06tgw/BMGItPQYjuvJVoHJS4XwTHClMc2ljX +PJUi2dHrb7LY5KzkXj6/fg9CHCxfWEM+ipyTo4QisrcS3pB2MgdnpMzS1m1rMoeH +Ei+QuNYbyH/mMxMpNHsnS8Pq0W59r3W9U4Lt5NLoEsN9GpZ8sF54hsqZN/4OTdC2 +U0CAmsbmvVjYNufSOM+Z8Q2oQvtEblSEcGgqEF/nh5jA+qydNcqPR+aaLx9arQfN +MP9gTobtMophbQA3ZmSYjjVLmfejHAhrIG5zzwIDAQABAoIBABbF5VPebsahBlvE +8rnidnKvyphwcHN8uNuoXfGavIr9AMioV8CLhHw64QVeHCSeglRolsFpIIeaYpz3 +Df7JTtiN6RlSOs7o9cgahC12jWsKtlRByMu6b1fQB6LBNc01kpbgolqRJf6hzzCE +TpiUPRGWVfd65F0TtccnLic+5/4uhaLSOfecS1jGxbFVGQ0eziXiOYqZz69YsnWd +cCSu4M0Vgivfn9WH1PS4XAqcCWO2htU2K05e5DBhBu+0oC+ErXESg7X1U5PjwVrW +zqGXhkNlJTMihM+7WRqey/9urvLzJCYfQRwezNpcLnPh5REemD1WiYlt3be5e1NA +beOZUkkCgYEA1TLNJeKIrg0Eghcx/bls0AULD6qNZ02kq7c6BiOTBau7NRWmbwPO +1YHwRqr1rEA4xYtP41PuQeIhGL5DwOFh4yKqyp01pFku3+PktlQezCl8Hvsa7hUs +y36Swy4+Eg9rZA0111Ktp7wJLm4XmgLZTPVPAM4hRAh2V76zqL63I+sCgYEAxN6h +saZEAfEGbfWB7JMwbDupJB7+0qzrxQZE8lNe+k6RzOD/JAxiSRiDmk6R2nEtob89 +rlai6bopBA45g1IfyzWHo4b/bZeHy3sa+WFEVkE8dyBBawEq3Y5jARrZM4NlIgnG +VtpM20VgyL/FLfo0mfTt6lG2vibbyqB3dWjMCq0CgYEAlO4g+ucNnbBARvQXGuvu +BD6RpIb6soA9mSqsoN829A4r/4A5PHHHicR0aZlBduuB/RU9YEsgM+vYPOWkhNes +vrNX5aP+delK4mHbQjbvMKWGLEozXL90BE9ODISAHbOhzEmiI+GAp5ymOUX0vMRi +seznHGPiPxk+OjtgW2+mlbMCgYAVp8uvh/OJJyMm60+cX2B/N1zWrVYohH720Ea7 +RTJ4ZDYjjEhkhbw2AC1RxvzCQ5raZPf6+mq3PRQP7ySibmEy8DN4aHwmaPm2B1ej +QPDMcCafj/vCMoGtl2EKmRJ1WSnBwcOAgEjeAdawnm+pLBGnMcsN8Gkip5Gby2T4 +lEuFjQKBgErZuKLPq0zCkUNKgVpDVWlYMpz+BlKUDtfrVG8NM3Aca/cSrdi2Emxw +bjsf9NbhLlHAiqbwtPSJIuiKCmzF7WRU97mwM+om8CyLN6oHsVoXp/Ap06mWIooi +tiEf0u4LKF2KQGsgZ2C7JynVAkGSzLUWvsqAeqMeQqAj1pQKs4Y5 +-----END RSA PRIVATE KEY----- diff --git a/terraform/docker.pub b/terraform/docker.pub new file mode 100644 index 0000000..c567805 --- /dev/null +++ b/terraform/docker.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCj9E3HzedWlXij4QXYRKDkwYT/jQ9TIqDtnTjkJk6ff6Rd9g5eE+Iu1ZkibP1K6Kgkh2o4ErpcYV3Tq2DD8EwYi09BiO68lWgclLhfBMcKUxzaWNc8lSLZ0etvstjkrORePr9+D0IcLF9YQz6KnJOjhCKytxLekHYyB2ekzNLWbWsyh4cSL5C41hvIf+YzEyk0eydLw+rRbn2vdb1Tgu3k0ugSw30alnywXniGypk3/g5N0LZTQICaxua9WNg259I4z5nxDahC+0RuVIRwaCoQX+eHmMD6rJ01yo9H5povH1qtB80w/2BOhu0yimFtADdmZJiONUuZ96McCGsgbnPP ec2-user@ip-172-31-70-78.ec2.internal diff --git a/terraform/main.tf b/terraform/main.tf new file mode 100644 index 0000000..9738c10 --- /dev/null +++ b/terraform/main.tf @@ -0,0 +1,26 @@ +data "aws_ami" "latestLinuxAMI" { + owners = ["amazon"] + most_recent = true + filter { + name = "name" + values = ["amzn2-ami-hvm-*-x86_64-gp2"] + } +} + +resource "aws_instance" "ec2" { + ami = data.aws_ami.latestLinuxAMI.id + instance_type = "t2.micro" + subnet_id = aws_subnet.this.id + iam_instance_profile = "LabInstanceProfile" + security_groups = [aws_security_group.docker_sg.id] + key_name = "docker" +} + + +resource "aws_ecr_repository" "database" { + name = "database" +} + +resource "aws_ecr_repository" "application" { + name = "application" +} \ No newline at end of file diff --git a/terraform/network.tf b/terraform/network.tf new file mode 100644 index 0000000..b4fd2a4 --- /dev/null +++ b/terraform/network.tf @@ -0,0 +1,13 @@ +data "aws_vpc" "default" { + default = true +} + +resource "aws_subnet" "this" { + vpc_id = data.aws_vpc.default.id + cidr_block = "172.31.128.0/20" + map_public_ip_on_launch = true + + tags = { + Name = "Public Subnet" + } +} \ No newline at end of file diff --git a/terraform/securitygroup.tf b/terraform/securitygroup.tf new file mode 100644 index 0000000..68970b4 --- /dev/null +++ b/terraform/securitygroup.tf @@ -0,0 +1,41 @@ +resource "aws_security_group" "docker_sg" { + name = "docker_security_group" + description = "Security group for Docker Compose app" + vpc_id = data.aws_vpc.default.id + + ingress { + from_port = 22 + to_port = 22 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + ingress { + from_port = 5001 + to_port = 5001 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + ingress { + from_port = 5002 + to_port = 5002 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + ingress { + from_port = 5003 + to_port = 5003 + 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"] + } + +tags = { + Terraform = "true" + Environment = "dev" + } +} diff --git a/terraform/terraform.tfstate b/terraform/terraform.tfstate new file mode 100644 index 0000000..ae3f065 --- /dev/null +++ b/terraform/terraform.tfstate @@ -0,0 +1,445 @@ +{ + "version": 4, + "terraform_version": "1.3.9", + "serial": 8, + "lineage": "73106bf0-260e-c6c8-57fd-9c554c6ab538", + "outputs": {}, + "resources": [ + { + "mode": "data", + "type": "aws_ami", + "name": "latestLinuxAMI", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "architecture": "x86_64", + "arn": "arn:aws:ec2:us-east-1::image/ami-05b5badc2f7ddd88d", + "block_device_mappings": [ + { + "device_name": "/dev/xvda", + "ebs": { + "delete_on_termination": "true", + "encrypted": "false", + "iops": "0", + "snapshot_id": "snap-07d0aaf53127ea133", + "throughput": "0", + "volume_size": "8", + "volume_type": "gp2" + }, + "no_device": "", + "virtual_name": "" + } + ], + "boot_mode": "", + "creation_date": "2023-02-24T09:54:00.000Z", + "deprecation_time": "2025-02-24T09:54:00.000Z", + "description": "Amazon Linux 2 AMI 2.0.20230221.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-05b5badc2f7ddd88d", + "image_id": "ami-05b5badc2f7ddd88d", + "image_location": "amazon/amzn2-ami-hvm-2.0.20230221.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.20230221.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-07d0aaf53127ea133", + "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_vpc", + "name": "default", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:244069240907:vpc/vpc-0c375df36a4e25b86", + "cidr_block": "172.31.0.0/16", + "cidr_block_associations": [ + { + "association_id": "vpc-cidr-assoc-0e99fad12f87beb2f", + "cidr_block": "172.31.0.0/16", + "state": "associated" + } + ], + "default": true, + "dhcp_options_id": "dopt-03a42c3fb651c17ce", + "enable_dns_hostnames": true, + "enable_dns_support": true, + "enable_network_address_usage_metrics": false, + "filter": null, + "id": "vpc-0c375df36a4e25b86", + "instance_tenancy": "default", + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "main_route_table_id": "rtb-021a57da877c4ff63", + "owner_id": "244069240907", + "state": null, + "tags": {}, + "timeouts": null + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "managed", + "type": "aws_ecr_repository", + "name": "application", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ecr:us-east-1:244069240907:repository/application", + "encryption_configuration": [ + { + "encryption_type": "AES256", + "kms_key": "" + } + ], + "force_delete": null, + "id": "application", + "image_scanning_configuration": [ + { + "scan_on_push": false + } + ], + "image_tag_mutability": "MUTABLE", + "name": "application", + "registry_id": "244069240907", + "repository_url": "244069240907.dkr.ecr.us-east-1.amazonaws.com/application", + "tags": {}, + "tags_all": {}, + "timeouts": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjoxMjAwMDAwMDAwMDAwfX0=" + } + ] + }, + { + "mode": "managed", + "type": "aws_ecr_repository", + "name": "database", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ecr:us-east-1:244069240907:repository/database", + "encryption_configuration": [ + { + "encryption_type": "AES256", + "kms_key": "" + } + ], + "force_delete": null, + "id": "database", + "image_scanning_configuration": [ + { + "scan_on_push": false + } + ], + "image_tag_mutability": "MUTABLE", + "name": "database", + "registry_id": "244069240907", + "repository_url": "244069240907.dkr.ecr.us-east-1.amazonaws.com/database", + "tags": {}, + "tags_all": {}, + "timeouts": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjoxMjAwMDAwMDAwMDAwfX0=" + } + ] + }, + { + "mode": "managed", + "type": "aws_instance", + "name": "ec2", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "ami": "ami-05b5badc2f7ddd88d", + "arn": "arn:aws:ec2:us-east-1:244069240907:instance/i-0b1e9233088e80cfa", + "associate_public_ip_address": true, + "availability_zone": "us-east-1f", + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open", + "capacity_reservation_target": [] + } + ], + "cpu_core_count": 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": "LabInstanceProfile", + "id": "i-0b1e9233088e80cfa", + "instance_initiated_shutdown_behavior": "stop", + "instance_state": "running", + "instance_type": "t2.micro", + "ipv6_address_count": 0, + "ipv6_addresses": [], + "key_name": "docker", + "launch_template": [], + "maintenance_options": [ + { + "auto_recovery": "default" + } + ], + "metadata_options": [ + { + "http_endpoint": "enabled", + "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-09f14146e9b4e8220", + "private_dns": "ip-172-31-137-200.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.137.200", + "public_dns": "ec2-3-235-77-26.compute-1.amazonaws.com", + "public_ip": "3.235.77.26", + "root_block_device": [ + { + "delete_on_termination": true, + "device_name": "/dev/xvda", + "encrypted": false, + "iops": 100, + "kms_key_id": "", + "tags": {}, + "throughput": 0, + "volume_id": "vol-0174584b6ab465186", + "volume_size": 8, + "volume_type": "gp2" + } + ], + "secondary_private_ips": [], + "security_groups": [ + "sg-07ccce6631c3ec977" + ], + "source_dest_check": true, + "subnet_id": "subnet-09d1b4944d86dfd07", + "tags": null, + "tags_all": {}, + "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-07ccce6631c3ec977" + ] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", + "dependencies": [ + "aws_security_group.docker_sg", + "aws_subnet.this", + "data.aws_ami.latestLinuxAMI" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_security_group", + "name": "docker_sg", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:244069240907:security-group/sg-07ccce6631c3ec977", + "description": "Security group for Docker Compose app", + "egress": [ + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "", + "from_port": 0, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "-1", + "security_groups": [], + "self": false, + "to_port": 0 + } + ], + "id": "sg-07ccce6631c3ec977", + "ingress": [ + { + "cidr_blocks": [ + "10.0.0.0/16" + ], + "description": "", + "from_port": 3306, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "tcp", + "security_groups": [], + "self": false, + "to_port": 3306 + }, + { + "cidr_blocks": [ + "10.0.0.0/16" + ], + "description": "", + "from_port": 5000, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "tcp", + "security_groups": [], + "self": false, + "to_port": 5000 + } + ], + "name": "docker_security_group", + "name_prefix": "", + "owner_id": "244069240907", + "revoke_rules_on_delete": false, + "tags": { + "Environment": "dev", + "Terraform": "true" + }, + "tags_all": { + "Environment": "dev", + "Terraform": "true" + }, + "timeouts": null, + "vpc_id": "vpc-0c375df36a4e25b86" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6OTAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIxIn0=", + "dependencies": [ + "data.aws_vpc.default" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_subnet", + "name": "this", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:244069240907:subnet/subnet-09d1b4944d86dfd07", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1f", + "availability_zone_id": "use1-az5", + "cidr_block": "172.31.128.0/20", + "customer_owned_ipv4_pool": "", + "enable_dns64": false, + "enable_resource_name_dns_a_record_on_launch": false, + "enable_resource_name_dns_aaaa_record_on_launch": false, + "id": "subnet-09d1b4944d86dfd07", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "ipv6_native": false, + "map_customer_owned_ip_on_launch": false, + "map_public_ip_on_launch": true, + "outpost_arn": "", + "owner_id": "244069240907", + "private_dns_hostname_type_on_launch": "ip-name", + "tags": { + "Name": "Public Subnet" + }, + "tags_all": { + "Name": "Public Subnet" + }, + "timeouts": null, + "vpc_id": "vpc-0c375df36a4e25b86" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "data.aws_vpc.default" + ] + } + ] + } + ], + "check_results": null +} diff --git a/terraform/terraform.tfstate.backup b/terraform/terraform.tfstate.backup new file mode 100644 index 0000000..ba7fd86 --- /dev/null +++ b/terraform/terraform.tfstate.backup @@ -0,0 +1,323 @@ +{ + "version": 4, + "terraform_version": "1.3.9", + "serial": 6, + "lineage": "73106bf0-260e-c6c8-57fd-9c554c6ab538", + "outputs": {}, + "resources": [ + { + "mode": "data", + "type": "aws_ami", + "name": "latestLinuxAMI", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "architecture": "x86_64", + "arn": "arn:aws:ec2:us-east-1::image/ami-05b5badc2f7ddd88d", + "block_device_mappings": [ + { + "device_name": "/dev/xvda", + "ebs": { + "delete_on_termination": "true", + "encrypted": "false", + "iops": "0", + "snapshot_id": "snap-07d0aaf53127ea133", + "throughput": "0", + "volume_size": "8", + "volume_type": "gp2" + }, + "no_device": "", + "virtual_name": "" + } + ], + "boot_mode": "", + "creation_date": "2023-02-24T09:54:00.000Z", + "deprecation_time": "2025-02-24T09:54:00.000Z", + "description": "Amazon Linux 2 AMI 2.0.20230221.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-05b5badc2f7ddd88d", + "image_id": "ami-05b5badc2f7ddd88d", + "image_location": "amazon/amzn2-ami-hvm-2.0.20230221.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.20230221.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-07d0aaf53127ea133", + "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_vpc", + "name": "default", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:244069240907:vpc/vpc-0c375df36a4e25b86", + "cidr_block": "172.31.0.0/16", + "cidr_block_associations": [ + { + "association_id": "vpc-cidr-assoc-0e99fad12f87beb2f", + "cidr_block": "172.31.0.0/16", + "state": "associated" + } + ], + "default": true, + "dhcp_options_id": "dopt-03a42c3fb651c17ce", + "enable_dns_hostnames": true, + "enable_dns_support": true, + "enable_network_address_usage_metrics": false, + "filter": null, + "id": "vpc-0c375df36a4e25b86", + "instance_tenancy": "default", + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "main_route_table_id": "rtb-021a57da877c4ff63", + "owner_id": "244069240907", + "state": null, + "tags": {}, + "timeouts": null + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "managed", + "type": "aws_ecr_repository", + "name": "application", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ecr:us-east-1:244069240907:repository/application", + "encryption_configuration": [ + { + "encryption_type": "AES256", + "kms_key": "" + } + ], + "force_delete": null, + "id": "application", + "image_scanning_configuration": [ + { + "scan_on_push": false + } + ], + "image_tag_mutability": "MUTABLE", + "name": "application", + "registry_id": "244069240907", + "repository_url": "244069240907.dkr.ecr.us-east-1.amazonaws.com/application", + "tags": null, + "tags_all": {}, + "timeouts": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjoxMjAwMDAwMDAwMDAwfX0=" + } + ] + }, + { + "mode": "managed", + "type": "aws_ecr_repository", + "name": "database", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ecr:us-east-1:244069240907:repository/database", + "encryption_configuration": [ + { + "encryption_type": "AES256", + "kms_key": "" + } + ], + "force_delete": null, + "id": "database", + "image_scanning_configuration": [ + { + "scan_on_push": false + } + ], + "image_tag_mutability": "MUTABLE", + "name": "database", + "registry_id": "244069240907", + "repository_url": "244069240907.dkr.ecr.us-east-1.amazonaws.com/database", + "tags": null, + "tags_all": {}, + "timeouts": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjoxMjAwMDAwMDAwMDAwfX0=" + } + ] + }, + { + "mode": "managed", + "type": "aws_security_group", + "name": "docker_sg", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:244069240907:security-group/sg-07ccce6631c3ec977", + "description": "Security group for Docker Compose app", + "egress": [ + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "", + "from_port": 0, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "-1", + "security_groups": [], + "self": false, + "to_port": 0 + } + ], + "id": "sg-07ccce6631c3ec977", + "ingress": [ + { + "cidr_blocks": [ + "10.0.0.0/16" + ], + "description": "", + "from_port": 3306, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "tcp", + "security_groups": [], + "self": false, + "to_port": 3306 + }, + { + "cidr_blocks": [ + "10.0.0.0/16" + ], + "description": "", + "from_port": 5000, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "tcp", + "security_groups": [], + "self": false, + "to_port": 5000 + } + ], + "name": "docker_security_group", + "name_prefix": "", + "owner_id": "244069240907", + "revoke_rules_on_delete": false, + "tags": { + "Environment": "dev", + "Terraform": "true" + }, + "tags_all": { + "Environment": "dev", + "Terraform": "true" + }, + "timeouts": null, + "vpc_id": "vpc-0c375df36a4e25b86" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6OTAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIxIn0=", + "dependencies": [ + "data.aws_vpc.default" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_subnet", + "name": "this", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:244069240907:subnet/subnet-09d1b4944d86dfd07", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1f", + "availability_zone_id": "use1-az5", + "cidr_block": "172.31.128.0/20", + "customer_owned_ipv4_pool": "", + "enable_dns64": false, + "enable_resource_name_dns_a_record_on_launch": false, + "enable_resource_name_dns_aaaa_record_on_launch": false, + "id": "subnet-09d1b4944d86dfd07", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "ipv6_native": false, + "map_customer_owned_ip_on_launch": false, + "map_public_ip_on_launch": true, + "outpost_arn": "", + "owner_id": "244069240907", + "private_dns_hostname_type_on_launch": "ip-name", + "tags": { + "Name": "Public Subnet" + }, + "tags_all": { + "Name": "Public Subnet" + }, + "timeouts": null, + "vpc_id": "vpc-0c375df36a4e25b86" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "data.aws_vpc.default" + ] + } + ] + } + ], + "check_results": null +}