Managing Applications and Infrastructure with Terraform-Deploying Infrastructure with Terraform-(2)Terraform for AWS-(13)Terraform Apply and Troubleshooting

2018年10月04日


Managing Applications and Infrastructure with Terraform-Deploying Infrastructure with Terraform
2. Terraform for AWS
13. Terraform Apply and Troubleshooting

ec2-user:~/environment/AWS $ pwd

/home/ec2-user/environment/AWS

ec2-user:~/environment/AWS $ terraform init
Initializing modules...
- compute in compute

Initializing the backend...

Initializing provider plugins...
- Using previously-installed hashicorp/aws v3.9.0
- Using previously-installed hashicorp/random v3.0.0
- Finding latest version of hashicorp/template...
- Installing hashicorp/template v2.2.0...
- Installed hashicorp/template v2.2.0 (signed by HashiCorp)

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, we recommend adding version constraints in a required_providers block
in your configuration, with the constraint strings suggested below.

* hashicorp/aws: version = "~> 3.9.0"
* hashicorp/random: version = "~> 3.0.0"
* hashicorp/template: version = "~> 2.2.0"

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

ec2-user:~/environment/AWS $ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.aws_availability_zones.available: Refreshing state...
data.aws_ami.server_ami: Refreshing state...

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create
 <= read (data resources)

Terraform will perform the following actions:

 <= module.compute.data.template_file.user-init[0]
      id:                                          <computed>
      rendered:                                    <computed>
      template:                                    "#!/bin/bash\nyum install httpd -y\necho \"Subnet for Firewall: ${firewall_subnets}\" >> /var/www/html/index.html\nservice httpd start\nchkconfig httpd on"
      vars.%:                                      "1"
      vars.firewall_subnets:                       "10.123.1.0/24"

 <= module.compute.data.template_file.user-init[1]
      id:                                          <computed>
      rendered:                                    <computed>
      template:                                    "#!/bin/bash\nyum install httpd -y\necho \"Subnet for Firewall: ${firewall_subnets}\" >> /var/www/html/index.html\nservice httpd start\nchkconfig httpd on"
      vars.%:                                      "1"
      vars.firewall_subnets:                       "10.123.2.0/24"

  + module.compute.aws_instance.tf_server[0]
      id:                                          <computed>
      ami:                                         "ami-a0cfeed8"
      arn:                                         <computed>
      associate_public_ip_address:                 <computed>
      availability_zone:                           <computed>
      cpu_core_count:                              <computed>
      cpu_threads_per_core:                        <computed>
      ebs_block_device.#:                          <computed>
      ephemeral_block_device.#:                    <computed>
      get_password_data:                           "false"
      instance_state:                              <computed>
      instance_type:                               "{var.server_instance_type}"
      ipv6_address_count:                          <computed>
      ipv6_addresses.#:                            <computed>
      key_name:                                    "${aws_key_pair.tf_auth.id}"
      network_interface.#:                         <computed>
      network_interface_id:                        <computed>
      password_data:                               <computed>
      placement_group:                             <computed>
      primary_network_interface_id:                <computed>
      private_dns:                                 <computed>
      private_ip:                                  <computed>
      public_dns:                                  <computed>
      public_ip:                                   <computed>
      root_block_device.#:                         <computed>
      security_groups.#:                           <computed>
      source_dest_check:                           "true"
      subnet_id:                                   "${element(var.subnets, count.index)}"
      tags.%:                                      "1"
      tags.Name:                                   "tf_server-1"
      tenancy:                                     <computed>
      user_data:                                   "67ae27e2ad64844cca1e04cc07bde51eb171c04b"
      volume_tags.%:                               <computed>
      vpc_security_group_ids.#:                    <computed>

  + module.compute.aws_instance.tf_server[1]
      id:                                          <computed>
      ami:                                         "ami-a0cfeed8"
      arn:                                         <computed>
      associate_public_ip_address:                 <computed>
      availability_zone:                           <computed>
      cpu_core_count:                              <computed>
      cpu_threads_per_core:                        <computed>
      ebs_block_device.#:                          <computed>
      ephemeral_block_device.#:                    <computed>
      get_password_data:                           "false"
      instance_state:                              <computed>
      instance_type:                               "{var.server_instance_type}"
      ipv6_address_count:                          <computed>
      ipv6_addresses.#:                            <computed>
      key_name:                                    "${aws_key_pair.tf_auth.id}"
      network_interface.#:                         <computed>
      network_interface_id:                        <computed>
      password_data:                               <computed>
      placement_group:                             <computed>
      primary_network_interface_id:                <computed>
      private_dns:                                 <computed>
      private_ip:                                  <computed>
      public_dns:                                  <computed>
      public_ip:                                   <computed>
      root_block_device.#:                         <computed>
      security_groups.#:                           <computed>
      source_dest_check:                           "true"
      subnet_id:                                   "${element(var.subnets, count.index)}"
      tags.%:                                      "1"
      tags.Name:                                   "tf_server-2"
      tenancy:                                     <computed>
      user_data:                                   "67ae27e2ad64844cca1e04cc07bde51eb171c04b"
      volume_tags.%:                               <computed>
      vpc_security_group_ids.#:                    <computed>

  + module.compute.aws_key_pair.tf_auth
      id:                                          <computed>
      fingerprint:                                 <computed>
      key_name:                                    "tf_key"
      public_key:                                  "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCnYE+D6epfc7eo5whpIlD6NS5tzVYJqm1RRWZoG2aloZO2AAPiSDQfQLoEOLv1DfHNvKBtckDR2ifyEb3thg/Ect+PNmk04qT9a6yGj4T5P+TW4y8P5ha4It3NyauNLXMKuzVu9M3dUOQbbFfnwGf8cE0pFqcw9bVlvhM5Lo68anyaTyH6+fwLCS0Q+sSFpmwY5LoGO0LknPyltcFmXU4xiX/gkT6+3KYE3JDKtDqNbskslemjfxDx+X3lzcbWVw1UayB69cKFS4MFkf2EVkXnCqSz9V2lks3270YJzbte/rtIUwbG+JRTDcqpsi1/zI2iOxOqdx+BER7bGpVc+WOZ ec2-user@ip-172-31-34-62"

  + module.networking.aws_default_route_table.tf_private_rt
      id:                                          <computed>
      default_route_table_id:                      "{aws_vpc.tf_vpc.default_route_table.id}"
      route.#:                                     <computed>
      tags.%:                                      "1"
      tags.Name:                                   "tf_private"
      vpc_id:                                      <computed>

  + module.networking.aws_internet_gateway.tf_internet_gateway
      id:                                          <computed>
      tags.%:                                      "1"
      tags.Name:                                   "tf_igw"
      vpc_id:                                      "${aws_vpc.tf_vpc.id}"

  + module.networking.aws_route_table.tf_public_rt
      id:                                          <computed>
      propagating_vgws.#:                          <computed>
      route.#:                                     "1"
      route.~4112294126.cidr_block:                "0.0.0.0/0"
      route.~4112294126.egress_only_gateway_id:    ""
      route.~4112294126.gateway_id:                "${aws_internet_gateway.tf_internet_gateway.id}"
      route.~4112294126.instance_id:               ""
      route.~4112294126.ipv6_cidr_block:           ""
      route.~4112294126.nat_gateway_id:            ""
      route.~4112294126.network_interface_id:      ""
      route.~4112294126.vpc_peering_connection_id: ""
      tags.%:                                      "1"
      tags.Name:                                   "tf_public"
      vpc_id:                                      "${aws_vpc.tf_vpc.id}"

  + module.networking.aws_route_table_association.tf_public_assoc[0]
      id:                                          <computed>
      route_table_id:                              "${aws_route_table.tf_public_rt.id}"
      subnet_id:                                   "${aws_subnet.tf_public_subnet.*.id[count.index]}"

  + module.networking.aws_route_table_association.tf_public_assoc[1]
      id:                                          <computed>
      route_table_id:                              "${aws_route_table.tf_public_rt.id}"
      subnet_id:                                   "${aws_subnet.tf_public_subnet.*.id[count.index]}"

  + module.networking.aws_security_group.tf_public_sg
      id:                                          <computed>
      arn:                                         <computed>
      description:                                 "Used for access to the public instances"
      egress.#:                                    "1"
      egress.482069346.cidr_blocks.#:              "1"
      egress.482069346.cidr_blocks.0:              "0.0.0.0/0"
      egress.482069346.description:                ""
      egress.482069346.from_port:                  "0"
      egress.482069346.ipv6_cidr_blocks.#:         "0"
      egress.482069346.prefix_list_ids.#:          "0"
      egress.482069346.protocol:                   "-1"
      egress.482069346.security_groups.#:          "0"
      egress.482069346.self:                       "false"
      egress.482069346.to_port:                    "0"
      ingress.#:                                   "2"
      ingress.2214680975.cidr_blocks.#:            "1"
      ingress.2214680975.cidr_blocks.0:            "0.0.0.0/0"
      ingress.2214680975.description:              ""
      ingress.2214680975.from_port:                "80"
      ingress.2214680975.ipv6_cidr_blocks.#:       "0"
      ingress.2214680975.prefix_list_ids.#:        "0"
      ingress.2214680975.protocol:                 "tcp"
      ingress.2214680975.security_groups.#:        "0"
      ingress.2214680975.self:                     "false"
      ingress.2214680975.to_port:                  "80"
      ingress.2541437006.cidr_blocks.#:            "1"
      ingress.2541437006.cidr_blocks.0:            "0.0.0.0/0"
      ingress.2541437006.description:              ""
      ingress.2541437006.from_port:                "22"
      ingress.2541437006.ipv6_cidr_blocks.#:       "0"
      ingress.2541437006.prefix_list_ids.#:        "0"
      ingress.2541437006.protocol:                 "tcp"
      ingress.2541437006.security_groups.#:        "0"
      ingress.2541437006.self:                     "false"
      ingress.2541437006.to_port:                  "22"
      name:                                        "tf_public_sg"
      owner_id:                                    <computed>
      revoke_rules_on_delete:                      "false"
      vpc_id:                                      "${aws_vpc.tf_vpc.id}"

  + module.networking.aws_subnet.tf_public_subnet[0]
      id:                                          <computed>
      arn:                                         <computed>
      assign_ipv6_address_on_creation:             "false"
      availability_zone:                           "us-west-2a"
      cidr_block:                                  "10.123.1.0/24"
      ipv6_cidr_block:                             <computed>
      ipv6_cidr_block_association_id:              <computed>
      map_public_ip_on_launch:                     "true"
      tags.%:                                      "1"
      tags.Name:                                   "tf_public_1"
      vpc_id:                                      "${aws_vpc.tf_vpc.id}"

  + module.networking.aws_subnet.tf_public_subnet[1]
      id:                                          <computed>
      arn:                                         <computed>
      assign_ipv6_address_on_creation:             "false"
      availability_zone:                           "us-west-2b"
      cidr_block:                                  "10.123.2.0/24"
      ipv6_cidr_block:                             <computed>
      ipv6_cidr_block_association_id:              <computed>
      map_public_ip_on_launch:                     "true"
      tags.%:                                      "1"
      tags.Name:                                   "tf_public_2"
      vpc_id:                                      "${aws_vpc.tf_vpc.id}"

  + module.networking.aws_vpc.tf_vpc
      id:                                          <computed>
      arn:                                         <computed>
      assign_generated_ipv6_cidr_block:            "false"
      cidr_block:                                  "10.123.0.0/16"
      default_network_acl_id:                      <computed>
      default_route_table_id:                      <computed>
      default_security_group_id:                   <computed>
      dhcp_options_id:                             <computed>
      enable_classiclink:                          <computed>
      enable_classiclink_dns_support:              <computed>
      enable_dns_hostnames:                        "true"
      enable_dns_support:                          "true"
      instance_tenancy:                            "default"
      ipv6_association_id:                         <computed>
      ipv6_cidr_block:                             <computed>
      main_route_table_id:                         <computed>
      tags.%:                                      "1"
      tags.Name:                                   "tf_vpc"

  + module.storage.aws_s3_bucket.tf_code
      id:                                          <computed>
      acceleration_status:                         <computed>
      acl:                                         "private"
      arn:                                         <computed>
      bucket:                                      "${var.project_name}-${random_id.tf_bucket_id.dec}"
      bucket_domain_name:                          <computed>
      bucket_regional_domain_name:                 <computed>
      force_destroy:                               "true"
      hosted_zone_id:                              <computed>
      region:                                      <computed>
      request_payer:                               <computed>
      tags.%:                                      "1"
      tags.Name:                                   "tf_bucket"
      versioning.#:                                <computed>
      website_domain:                              <computed>
      website_endpoint:                            <computed>

  + module.storage.random_id.tf_bucket_id
      id:                                          <computed>
      b64:                                         <computed>
      b64_std:                                     <computed>
      b64_url:                                     <computed>
      byte_length:                                 "2"
      dec:                                         <computed>
      hex:                                         <computed>


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

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

ec2-user:~/environment/AWS $ terraform apply
module.networking.data.aws_availability_zones.available: Refreshing state...
module.compute.data.aws_ami.server_ami: Refreshing state...

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create
 <= read (data resources)

Terraform will perform the following actions:

  # module.compute.data.template_file.user-init[0] will be read during apply
  # (config refers to values not yet known)
 <= data "template_file" "user-init"  {
      + id       = "57df141e108f0b6cf1703691b1a5a736ca3a01b0eb84e07196d778d405c36d19"
      + rendered = <<~EOT
            #!/bin/bash
            yum install httpd -y
            echo "Subnet for Firewall: 10.123.1.0/24" >> /var/www/html/index.html
            service httpd start
            chkconfig httpd on
        EOT
      + template = <<~EOT
            #!/bin/bash
            yum install httpd -y
            echo "Subnet for Firewall: ${firewall_subnets}" >> /var/www/html/index.html
            service httpd start
            chkconfig httpd on
        EOT
      + vars     = {
          + "firewall_subnets" = "10.123.1.0/24"
        }
    }

  # module.compute.data.template_file.user-init[1] will be read during apply
  # (config refers to values not yet known)
 <= data "template_file" "user-init"  {
      + id       = "757bacc9f6377916bf38eff5b6acdb9ae2756c56859b9c203d8de26eff4865d4"
      + rendered = <<~EOT
            #!/bin/bash
            yum install httpd -y
            echo "Subnet for Firewall: 10.123.2.0/24" >> /var/www/html/index.html
            service httpd start
            chkconfig httpd on
        EOT
      + template = <<~EOT
            #!/bin/bash
            yum install httpd -y
            echo "Subnet for Firewall: ${firewall_subnets}" >> /var/www/html/index.html
            service httpd start
            chkconfig httpd on
        EOT
      + vars     = {
          + "firewall_subnets" = "10.123.2.0/24"
        }
    }

  # module.compute.aws_instance.tf_server[0] will be created
  + resource "aws_instance" "tf_server" {
      + ami                          = "ami-01fee56b22f308154"
      + arn                          = (known after apply)
      + associate_public_ip_address  = (known after apply)
      + availability_zone            = (known after apply)
      + cpu_core_count               = (known after apply)
      + cpu_threads_per_core         = (known after apply)
      + get_password_data            = false
      + host_id                      = (known after apply)
      + id                           = (known after apply)
      + instance_state               = (known after apply)
      + instance_type                = "t2.micro"
      + ipv6_address_count           = (known after apply)
      + ipv6_addresses               = (known after apply)
      + key_name                     = (known after apply)
      + outpost_arn                  = (known after apply)
      + password_data                = (known after apply)
      + placement_group              = (known after apply)
      + primary_network_interface_id = (known after apply)
      + private_dns                  = (known after apply)
      + private_ip                   = (known after apply)
      + public_dns                   = (known after apply)
      + public_ip                    = (known after apply)
      + secondary_private_ips        = (known after apply)
      + security_groups              = (known after apply)
      + source_dest_check            = true
      + subnet_id                    = (known after apply)
      + tags                         = {
          + "Name" = "tf_server-1"
        }
      + tenancy                      = (known after apply)
      + user_data                    = "544105fc76f56380fa17cd0686e033cee5001d87"
      + volume_tags                  = (known after apply)
      + vpc_security_group_ids       = (known after apply)

      + ebs_block_device {
          + delete_on_termination = (known after apply)
          + device_name           = (known after apply)
          + encrypted             = (known after apply)
          + iops                  = (known after apply)
          + kms_key_id            = (known after apply)
          + snapshot_id           = (known after apply)
          + volume_id             = (known after apply)
          + volume_size           = (known after apply)
          + volume_type           = (known after apply)
        }

      + ephemeral_block_device {
          + device_name  = (known after apply)
          + no_device    = (known after apply)
          + virtual_name = (known after apply)
        }

      + metadata_options {
          + http_endpoint               = (known after apply)
          + http_put_response_hop_limit = (known after apply)
          + http_tokens                 = (known after apply)
        }

      + network_interface {
          + delete_on_termination = (known after apply)
          + device_index          = (known after apply)
          + network_interface_id  = (known after apply)
        }

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

  # module.compute.aws_instance.tf_server[1] will be created
  + resource "aws_instance" "tf_server" {
      + ami                          = "ami-01fee56b22f308154"
      + arn                          = (known after apply)
      + associate_public_ip_address  = (known after apply)
      + availability_zone            = (known after apply)
      + cpu_core_count               = (known after apply)
      + cpu_threads_per_core         = (known after apply)
      + get_password_data            = false
      + host_id                      = (known after apply)
      + id                           = (known after apply)
      + instance_state               = (known after apply)
      + instance_type                = "t2.micro"
      + ipv6_address_count           = (known after apply)
      + ipv6_addresses               = (known after apply)
      + key_name                     = (known after apply)
      + outpost_arn                  = (known after apply)
      + password_data                = (known after apply)
      + placement_group              = (known after apply)
      + primary_network_interface_id = (known after apply)
      + private_dns                  = (known after apply)
      + private_ip                   = (known after apply)
      + public_dns                   = (known after apply)
      + public_ip                    = (known after apply)
      + secondary_private_ips        = (known after apply)
      + security_groups              = (known after apply)
      + source_dest_check            = true
      + subnet_id                    = (known after apply)
      + tags                         = {
          + "Name" = "tf_server-2"
        }
      + tenancy                      = (known after apply)
      + user_data                    = "ea5b38a77b74322af7f46802b7e74b3277c7eb0d"
      + volume_tags                  = (known after apply)
      + vpc_security_group_ids       = (known after apply)

      + ebs_block_device {
          + delete_on_termination = (known after apply)
          + device_name           = (known after apply)
          + encrypted             = (known after apply)
          + iops                  = (known after apply)
          + kms_key_id            = (known after apply)
          + snapshot_id           = (known after apply)
          + volume_id             = (known after apply)
          + volume_size           = (known after apply)
          + volume_type           = (known after apply)
        }

      + ephemeral_block_device {
          + device_name  = (known after apply)
          + no_device    = (known after apply)
          + virtual_name = (known after apply)
        }

      + metadata_options {
          + http_endpoint               = (known after apply)
          + http_put_response_hop_limit = (known after apply)
          + http_tokens                 = (known after apply)
        }

      + network_interface {
          + delete_on_termination = (known after apply)
          + device_index          = (known after apply)
          + network_interface_id  = (known after apply)
        }

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

  # module.compute.aws_key_pair.tf_auth will be created
  + resource "aws_key_pair" "tf_auth" {
      + arn         = (known after apply)
      + fingerprint = (known after apply)
      + id          = (known after apply)
      + key_name    = "tf_key"
      + key_pair_id = (known after apply)
      + public_key  = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzIeDhLeOVMfyYVV4ePCm/X4uRRmqkqq84TU2VsBDHWtMuFwBbez2ZmAm+WQ5zOyaZC/soSK17R8TsociZ+9wJBWT62aS3H8IHE2UxoakjlucF1QLM81oZaO5R4DCeKVJb0l/XfZ/fQkhYFLNM5622MbHP8MTTwfrbwE1+hjRFJYb0K364NCD0BLdgn+V7kfyEcSRRds8gh8zdiejJxFHRTaq9LRx+AQwFDkQYEYzk6ZGxIasKonCD18OtwAePdFgA1Mlho6Ajh9VyrgYWrEHKmfvDa/Rz7T/cCy5tkzdu5B04HWI7yBEthZeKm9QA8keOj1xU+yMWSNwUhiXGTg85 ec2-user@ip-10-0-0-44.us-west-2.compute.internal"
    }

  # module.networking.aws_default_route_table.tf_private_rt will be created
  + resource "aws_default_route_table" "tf_private_rt" {
      + default_route_table_id = (known after apply)
      + id                     = (known after apply)
      + owner_id               = (known after apply)
      + route                  = (known after apply)
      + tags                   = {
          + "Name" = "tf_private"
        }
      + vpc_id                 = (known after apply)
    }

  # module.networking.aws_internet_gateway.tf_internet_gateway will be created
  + resource "aws_internet_gateway" "tf_internet_gateway" {
      + arn      = (known after apply)
      + id       = (known after apply)
      + owner_id = (known after apply)
      + tags     = {
          + "Name" = "tf_igw"
        }
      + vpc_id   = (known after apply)
    }

  # module.networking.aws_route_table.tf_public_rt will be created
  + resource "aws_route_table" "tf_public_rt" {
      + id               = (known after apply)
      + owner_id         = (known after apply)
      + propagating_vgws = (known after apply)
      + route            = [
          + {
              + cidr_block                = "0.0.0.0/0"
              + egress_only_gateway_id    = ""
              + gateway_id                = (known after apply)
              + instance_id               = ""
              + ipv6_cidr_block           = ""
              + local_gateway_id          = ""
              + nat_gateway_id            = ""
              + network_interface_id      = ""
              + transit_gateway_id        = ""
              + vpc_peering_connection_id = ""
            },
        ]
      + tags             = {
          + "Name" = "tf_public"
        }
      + vpc_id           = (known after apply)
    }

  # module.networking.aws_route_table_association.tf_public_assoc[0] will be created
  + resource "aws_route_table_association" "tf_public_assoc" {
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + subnet_id      = (known after apply)
    }

  # module.networking.aws_route_table_association.tf_public_assoc[1] will be created
  + resource "aws_route_table_association" "tf_public_assoc" {
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + subnet_id      = (known after apply)
    }

  # module.networking.aws_security_group.tf_public_sg will be created
  + resource "aws_security_group" "tf_public_sg" {
      + arn                    = (known after apply)
      + description            = "Used for access to the public instances"
      + 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                     = (known after apply)
      + ingress                = [
          + {
              + cidr_blocks      = [
                  + "0.0.0.0/0",
                ]
              + description      = ""
              + from_port        = 22
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "tcp"
              + security_groups  = []
              + self             = false
              + to_port          = 22
            },
          + {
              + cidr_blocks      = [
                  + "0.0.0.0/0",
                ]
              + description      = ""
              + from_port        = 80
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "tcp"
              + security_groups  = []
              + self             = false
              + to_port          = 80
            },
        ]
      + name                   = "tf_public_sg"
      + owner_id               = (known after apply)
      + revoke_rules_on_delete = false
      + vpc_id                 = (known after apply)
    }

  # module.networking.aws_subnet.tf_public_subnet[0] will be created
  + resource "aws_subnet" "tf_public_subnet" {
      + arn                             = (known after apply)
      + assign_ipv6_address_on_creation = false
      + availability_zone               = "us-west-2a"
      + availability_zone_id            = (known after apply)
      + cidr_block                      = "10.123.1.0/24"
      + id                              = (known after apply)
      + ipv6_cidr_block_association_id  = (known after apply)
      + map_public_ip_on_launch         = true
      + owner_id                        = (known after apply)
      + tags                            = {
          + "Name" = "tf_public_1"
        }
      + vpc_id                          = (known after apply)
    }

  # module.networking.aws_subnet.tf_public_subnet[1] will be created
  + resource "aws_subnet" "tf_public_subnet" {
      + arn                             = (known after apply)
      + assign_ipv6_address_on_creation = false
      + availability_zone               = "us-west-2b"
      + availability_zone_id            = (known after apply)
      + cidr_block                      = "10.123.2.0/24"
      + id                              = (known after apply)
      + ipv6_cidr_block_association_id  = (known after apply)
      + map_public_ip_on_launch         = true
      + owner_id                        = (known after apply)
      + tags                            = {
          + "Name" = "tf_public_2"
        }
      + vpc_id                          = (known after apply)
    }

  # module.networking.aws_vpc.tf_vpc will be created
  + resource "aws_vpc" "tf_vpc" {
      + arn                              = (known after apply)
      + assign_generated_ipv6_cidr_block = false
      + cidr_block                       = "10.123.0.0/16"
      + default_network_acl_id           = (known after apply)
      + default_route_table_id           = (known after apply)
      + default_security_group_id        = (known after apply)
      + dhcp_options_id                  = (known after apply)
      + enable_classiclink               = (known after apply)
      + enable_classiclink_dns_support   = (known after apply)
      + enable_dns_hostnames             = true
      + enable_dns_support               = true
      + id                               = (known after apply)
      + instance_tenancy                 = "default"
      + ipv6_association_id              = (known after apply)
      + ipv6_cidr_block                  = (known after apply)
      + main_route_table_id              = (known after apply)
      + owner_id                         = (known after apply)
      + tags                             = {
          + "Name" = "tf_vpc"
        }
    }

  # module.storage.aws_s3_bucket.tf_code will be created
  + resource "aws_s3_bucket" "tf_code" {
      + acceleration_status         = (known after apply)
      + acl                         = "private"
      + arn                         = (known after apply)
      + bucket                      = (known after apply)
      + bucket_domain_name          = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = true
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
      + tags                        = {
          + "Name" = "tf_bucket"
        }
      + website_domain              = (known after apply)
      + website_endpoint            = (known after apply)

      + versioning {
          + enabled    = (known after apply)
          + mfa_delete = (known after apply)
        }
    }

  # module.storage.random_id.tf_bucket_id will be created
  + resource "random_id" "tf_bucket_id" {
      + b64_std     = (known after apply)
      + b64_url     = (known after apply)
      + byte_length = 2
      + dec         = (known after apply)
      + hex         = (known after apply)
      + id          = (known after apply)
    }

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

Changes to Outputs:
  + Bucket_Name = (known after apply)

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.storage.random_id.tf_bucket_id: Creating...
module.storage.random_id.tf_bucket_id: Creation complete after 0s [id=4xI]
module.compute.aws_key_pair.tf_auth: Creating...
module.networking.aws_vpc.tf_vpc: Creating...
module.storage.aws_s3_bucket.tf_code: Creating...
module.compute.aws_key_pair.tf_auth: Creation complete after 0s [id=tf_key]
module.networking.aws_vpc.tf_vpc: Creation complete after 1s [id=vpc-0c0f2da28642867e2]
module.networking.aws_subnet.tf_public_subnet[0]: Creating...
module.networking.aws_default_route_table.tf_private_rt: Creating...
module.networking.aws_security_group.tf_public_sg: Creating...
module.networking.aws_internet_gateway.tf_internet_gateway: Creating...
module.networking.aws_subnet.tf_public_subnet[1]: Creating...
module.networking.aws_default_route_table.tf_private_rt: Creation complete after 0s [id=rtb-0566a0d7669788905]
module.networking.aws_internet_gateway.tf_internet_gateway: Creation complete after 1s [id=igw-0818bad4ef2e5e206]
module.networking.aws_route_table.tf_public_rt: Creating...
module.networking.aws_subnet.tf_public_subnet[0]: Creation complete after 1s [id=subnet-0c77cbd47f0f92385]
module.networking.aws_subnet.tf_public_subnet[1]: Creation complete after 1s [id=subnet-0e8c8b7fbe145ccd4]
module.compute.data.template_file.user-init[1]: Reading...
module.compute.data.template_file.user-init[1]: Read complete after 0s [id=757bacc9f6377916bf38eff5b6acdb9ae2756c56859b9c203d8de26eff4865d4]
module.compute.data.template_file.user-init[0]: Reading...
module.compute.data.template_file.user-init[0]: Read complete after 0s [id=57df141e108f0b6cf1703691b1a5a736ca3a01b0eb84e07196d778d405c36d19]
module.networking.aws_route_table.tf_public_rt: Creation complete after 0s [id=rtb-0ee0f448101c559a6]
module.networking.aws_route_table_association.tf_public_assoc[1]: Creating...
module.networking.aws_route_table_association.tf_public_assoc[0]: Creating...
module.networking.aws_route_table_association.tf_public_assoc[1]: Creation complete after 0s [id=rtbassoc-0f08e4f20a29c75dc]
module.networking.aws_route_table_association.tf_public_assoc[0]: Creation complete after 0s [id=rtbassoc-069833977e56c8e1f]
module.storage.aws_s3_bucket.tf_code: Creation complete after 3s [id=la-terrafrom-58130]
module.networking.aws_security_group.tf_public_sg: Creation complete after 2s [id=sg-08b6452d00a14dc79]
module.compute.aws_instance.tf_server[0]: Creating...
module.compute.aws_instance.tf_server[1]: Creating...
module.compute.aws_instance.tf_server[1]: Still creating... [10s elapsed]
module.compute.aws_instance.tf_server[0]: Still creating... [10s elapsed]
module.compute.aws_instance.tf_server[1]: Still creating... [20s elapsed]
module.compute.aws_instance.tf_server[0]: Still creating... [20s elapsed]
module.compute.aws_instance.tf_server[0]: Creation complete after 21s [id=i-043f7e57528e1a6a3]
module.compute.aws_instance.tf_server[1]: Creation complete after 21s [id=i-08364976098583f3b]

Apply complete! Resources: 14 added, 0 changed, 0 destroyed.

Outputs:

Bucket_Name = la-terrafrom-58130



Category: orchestration Tags: public

Upvote


Downvote