Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lorenzoaiello/d5b99d1bb0393aca078c2d1af8ade533 to your computer and use it in GitHub Desktop.
Save lorenzoaiello/d5b99d1bb0393aca078c2d1af8ade533 to your computer and use it in GitHub Desktop.
dc34vo-02
# apply from https://gist.github.com/lorenzoaiello/bcb5e57d3f1da2bdc43c2c808565f6e9
$ docker run -it -v $(pwd):/workspace -v $HOME/.aws:/home/.aws -e "HOME=/home" -w /workspace hashicorp/terraform:light apply
aws_route53_zone.main: Refreshing state... [id=Z1XB1I9YEXBEWV]
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# aws_route53_zone.main will be updated in-place
~ resource "aws_route53_zone" "main" {
+ comment = "Managed by Terraform"
+ force_destroy = false
id = "Z1XB1I9YEXBEWV"
name = "dc34vo.com."
name_servers = [
"ns-1187.awsdns-20.org",
"ns-1839.awsdns-37.co.uk",
"ns-23.awsdns-02.com",
"ns-674.awsdns-20.net",
]
~ tags = {
+ "Environment" = "PROD"
+ "Name" = "dc34vo.com Production Zone"
}
zone_id = "Z1XB1I9YEXBEWV"
}
Plan: 0 to add, 1 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_route53_zone.main: Modifying... [id=Z1XB1I9YEXBEWV]
aws_route53_zone.main: Modifications complete after 1s [id=Z1XB1I9YEXBEWV]
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
@weeping-somnambulist
Copy link

AWS ZONES

➜ aws route53 list-hosted-zones                                                                                                                                  
{
    "HostedZones": [
        {
            "Id": "/hostedzone/ZYUXTKMYT2R0J",
            "ResourceRecordSetCount": 2,
            "CallerReference": "RISWorkflow-RD:743186c2-7636-4a5b-b7e6-b9c03c4a9056",
            "Config": {
                "PrivateZone": false,
                "Comment": "HostedZone created by Route53 Registrar"
            },
            "Name": "foo.example."
        }
    ]
}

TF FILES

➜ ls 
dns.tf  provider.tf  terraform.tfstate  terraform.tfstate.backup  versions.tf
➜ cat dns.tf 
resource "aws_route53_zone" "main" {
  name = "foo.example"

  tags = {
    Environment = "PROD"
    Name = " Production Zone"
  }
}
➜ cat provider.tf 
provider "aws" {
  profile = "default"
  region  = "us-east-2"
}
➜ cat versions.tf 
terraform {
  required_version = ">= 0.12"
}

TF VERSION

Terraform v0.12.9

INIT

➜ docker run -it -v $(pwd):/workspace -v $HOME/.aws:/home/.aws -e "HOME=/home" -w /workspace hashicorp/terraform:light init

Initializing the backend...

Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "aws" (hashicorp/aws) 2.30.0...

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, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.

* provider.aws: version = "~> 2.30"

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.

PLAN

➜ docker run -it -v $(pwd):/workspace -v $HOME/.aws:/home/.aws -e "HOME=/home" -w /workspace hashicorp/terraform:light 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.


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

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_route53_zone.main will be created
  + resource "aws_route53_zone" "main" {
      + comment       = "Managed by Terraform"
      + force_destroy = false
      + id            = (known after apply)
      + name          = "foo.e"
      + name_servers  = (known after apply)
      + tags          = {
          + "Environment" = "PROD"
          + "Name"        = " Production Zone"
        }
      + vpc_id        = (known after apply)
      + vpc_region    = (known after apply)
      + zone_id       = (known after apply)
    }

Plan: 1 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.

IMPORT

➜ docker run -it -v $(pwd):/workspace -v $HOME/.aws:/home/.aws -e "HOME=/home" -w /workspace hashicorp/terraform:light import aws_route53_zone.main ZYUXTKMYT2R0J
aws_route53_zone.main: Importing from ID "ZYUXTKMYT2R0J"...
aws_route53_zone.main: Import prepared!
  Prepared aws_route53_zone for import
aws_route53_zone.main: Refreshing state... [id=ZYUXTKMYT2R0J]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

APPLY

➜ docker run -it -v $(pwd):/workspace -v $HOME/.aws:/home/.aws -e "HOME=/home" -w /workspace hashicorp/terraform:light apply
aws_route53_zone.main: Refreshing state... [id=ZYUXTKMYT2R0J]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_route53_zone.main will be updated in-place
  ~ resource "aws_route53_zone" "main" {
      ~ comment       = "HostedZone created by Route53 Registrar" -> "Managed by Terraform"
      + force_destroy = false
        id            = "ZYUXTKMYT2R0J"
        name          = "foo.example."
        name_servers  = [
            "ns-1335.awsdns-38.org",
            "ns-2025.awsdns-61.co.uk",
            "ns-54.awsdns-06.com",
            "ns-681.awsdns-21.net",
        ]
      ~ tags          = {
          + "Environment" = "PROD"
          + "Name"        = " Production Zone"
        }
        zone_id       = "ZYUXTKMYT2R0J"
    }

Plan: 0 to add, 1 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_route53_zone.main: Modifying... [id=ZYUXTKMYT2R0J]
aws_route53_zone.main: Modifications complete after 2s [id=ZYUXTKMYT2R0J]

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

RESULT

➜ aws route53 list-hosted-zones
{
    "HostedZones": [
        {
            "Id": "/hostedzone/ZYUXTKMYT2R0J",
            "Config": {
                "PrivateZone": false,
                "Comment": "HostedZone created by Route53 Registrar"
            },
            "ResourceRecordSetCount": 2,
            "Name": "foo.example.",
            "CallerReference": "RISWorkflow-RD:743186c2-7636-4a5b-b7e6-b9c03c4a9056"
        },
        {
            "Id": "/hostedzone/Z1JG2NRWAQLNI1",
            "Config": {
                "PrivateZone": false,
                "Comment": "Managed by Terraform"
            },
            "ResourceRecordSetCount": 2,
            "Name": "foo.example.",
            "CallerReference": "terraform-20191002012454857800000002"
        }
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment