Difference between revisions of "Terraform apply: ec2 instance example (aws instance module)"

From wikieduonline
Jump to navigation Jump to search
 
(30 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/examples/basic
 
https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/examples/basic
  
== [[Region]] missing ==
+
* <code>[[terraform apply]]</code>
terraform apply
+
* <code>[[terraform apply -auto-approve]]</code>
 
│ Error: Missing required argument
 
 
│ The argument "region" is required, but was not set.
 
 
  
== With errors  ==
+
* Resource: <code>[[aws_instance]]</code>
 +
* [[aws instance example]]: <code>[[main.tf]]</code>
  
<code>[[terraform]] apply</code>
+
== Apply complete! ==
 
<pre>
 
<pre>
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
+
terraform apply
following symbols:
+
 
 +
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with
 +
the following symbols:
 
   + create
 
   + create
  
 
Terraform will perform the following actions:
 
Terraform will perform the following actions:
  
   # module.ec2_cluster.aws_instance.this[0] will be created
+
   # aws_instance.example will be created
   + resource "aws_instance" "this" {
+
   + resource "aws_instance" "example" {
       + ami                                  = "ami-ebd02392"
+
       + ami                                  = "ami-08d70e59c07c61a3a"
 
       + arn                                  = (known after apply)
 
       + arn                                  = (known after apply)
 
       + associate_public_ip_address          = (known after apply)
 
       + associate_public_ip_address          = (known after apply)
Line 27: Line 25:
 
       + cpu_core_count                      = (known after apply)
 
       + cpu_core_count                      = (known after apply)
 
       + cpu_threads_per_core                = (known after apply)
 
       + cpu_threads_per_core                = (known after apply)
       + disable_api_termination              = false
+
       + disable_api_termination              = (known after apply)
       + ebs_optimized                        = false
+
       + ebs_optimized                        = (known after apply)
 
       + get_password_data                    = false
 
       + get_password_data                    = false
 
       + host_id                              = (known after apply)
 
       + host_id                              = (known after apply)
Line 37: Line 35:
 
       + ipv6_address_count                  = (known after apply)
 
       + ipv6_address_count                  = (known after apply)
 
       + ipv6_addresses                      = (known after apply)
 
       + ipv6_addresses                      = (known after apply)
       + key_name                            = "user1"
+
       + key_name                            = (known after apply)
       + monitoring                          = false
+
       + monitoring                          = (known after apply)
 
       + outpost_arn                          = (known after apply)
 
       + outpost_arn                          = (known after apply)
 
       + password_data                        = (known after apply)
 
       + password_data                        = (known after apply)
Line 50: Line 48:
 
       + security_groups                      = (known after apply)
 
       + security_groups                      = (known after apply)
 
       + source_dest_check                    = true
 
       + source_dest_check                    = true
       + subnet_id                            = "subnet-eddcdzz4"
+
       + subnet_id                            = (known after apply)
 
       + tags                                = {
 
       + tags                                = {
          + "Environment" = "dev"
+
           + "Name" = "ExampleAppServerInstance"
           + "Name"       = "my-instance"
 
          + "Terraform"  = "true"
 
 
         }
 
         }
 
       + tags_all                            = {
 
       + tags_all                            = {
          + "Environment" = "dev"
+
           + "Name" = "ExampleAppServerInstance"
           + "Name"       = "my-instance"
 
          + "Terraform"  = "true"
 
 
         }
 
         }
       + tenancy                              = "default"
+
       + tenancy                              = (known after apply)
 
       + user_data                            = (known after apply)
 
       + user_data                            = (known after apply)
 
       + user_data_base64                    = (known after apply)
 
       + user_data_base64                    = (known after apply)
      + volume_tags                          = {
+
       + vpc_security_group_ids              = (known after apply)
          + "Name" = "my-instance"
 
        }
 
       + vpc_security_group_ids              = [
 
          + "sg-12345678",
 
        ]
 
  
 
       + capacity_reservation_specification {
 
       + capacity_reservation_specification {
Line 77: Line 66:
 
               + capacity_reservation_id = (known after apply)
 
               + capacity_reservation_id = (known after apply)
 
             }
 
             }
        }
 
 
      + credit_specification {
 
          + cpu_credits = "standard"
 
 
         }
 
         }
  
Line 140: Line 125:
  
 
   Enter a value: yes
 
   Enter a value: yes
 +
 +
aws_instance.example: Creating...
 +
aws_instance.example: Still creating... [10s elapsed]
 +
aws_instance.example: Still creating... [20s elapsed]
 +
aws_instance.example: Still creating... [30s elapsed]
 +
aws_instance.example: Still creating... [40s elapsed]
 +
aws_instance.example: Creation complete after 43s [id=i-079b8300c42bea5c3]
 +
 +
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
 
</pre>
 
</pre>
 
module.ec2_cluster.aws_instance.this[0]: Creating...
 
 
│ Error: Error launching source instance: InvalidAMIID.NotFound: The image id '[ami-ebd02392]' does not exist
 
│      status code: 400, request id: 3875ad13-7a52-4026-8cca-6f6bbf1133d9
 
 
│  with module.ec2_cluster.aws_instance.this[0],
 
│  on .terraform/modules/ec2_cluster/main.tf line 5, in resource "aws_instance" "this":
 
│    5: resource "aws_instance" "this" {
 
 
 
  
 +
== Related ==
 +
* [[Terraform apply examples with errors]]
 +
* <code>[[terraform show]]</code>
 +
* Terraform module: <code>[[ec2-instance]]</code>
 +
* [[Terraform resource: aws_volume_attachment]]
 +
[[ebs_block_device]]
  
 
== See also ==
 
== See also ==
* {{terraform cmd}}
+
* {{tf ec2}}
 +
* {{terraform apply}}
 +
 
  
 
[[Category:Terraform]]
 
[[Category:Terraform]]

Latest revision as of 08:08, 15 February 2023

https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/examples/basic

Apply complete![edit]

terraform apply

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

Terraform will perform the following actions:

  # aws_instance.example will be created
  + resource "aws_instance" "example" {
      + ami                                  = "ami-08d70e59c07c61a3a"
      + 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)
      + disable_api_termination              = (known after apply)
      + ebs_optimized                        = (known after apply)
      + get_password_data                    = false
      + host_id                              = (known after apply)
      + id                                   = (known after apply)
      + instance_initiated_shutdown_behavior = (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)
      + monitoring                           = (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" = "ExampleAppServerInstance"
        }
      + tags_all                             = {
          + "Name" = "ExampleAppServerInstance"
        }
      + tenancy                              = (known after apply)
      + user_data                            = (known after apply)
      + user_data_base64                     = (known after apply)
      + vpc_security_group_ids               = (known after apply)

      + capacity_reservation_specification {
          + capacity_reservation_preference = (known after apply)

          + capacity_reservation_target {
              + capacity_reservation_id = (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)
          + tags                  = (known after apply)
          + throughput            = (known after apply)
          + volume_id             = (known after apply)
          + volume_size           = (known after apply)
          + volume_type           = (known after apply)
        }

      + enclave_options {
          + enabled = (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)
          + tags                  = (known after apply)
          + throughput            = (known after apply)
          + volume_id             = (known after apply)
          + volume_size           = (known after apply)
          + volume_type           = (known after apply)
        }
    }

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

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

aws_instance.example: Creating...
aws_instance.example: Still creating... [10s elapsed]
aws_instance.example: Still creating... [20s elapsed]
aws_instance.example: Still creating... [30s elapsed]
aws_instance.example: Still creating... [40s elapsed]
aws_instance.example: Creation complete after 43s [id=i-079b8300c42bea5c3]

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

Related[edit]

ebs_block_device

See also[edit]

Advertising: