Skip to content

Instantly share code, notes, and snippets.

@waltervargas
Created June 27, 2017 23:16
Show Gist options
  • Save waltervargas/c8ffa3049eb080255db1430c06507279 to your computer and use it in GitHub Desktop.
Save waltervargas/c8ffa3049eb080255db1430c06507279 to your computer and use it in GitHub Desktop.

Summary

Steps

Terraform Init

Terraform Plan

Terraform Apply

Terraform Plan

❯ ~/git/terraform/bin/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.

aws_s3_bucket.w: Refreshing state... (ID: my_tf_test_bucket_w)
No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, Terraform
doesn't need to do anything.

Change the file .terraform/terraform.tfstate

Before Change It

{
    "version": 3,
    "serial": 0,
    "lineage": "15b3c30a-628a-4afe-84ec-9dedbd0c3f38",
    "backend": {
        "type": "s3",
        "config": {
            "bucket": "walter-devops-us-east-1",
            "encrypt": true,
            "key": "terraform/dev/terraform.tfstate",
            "region": "us-east-1"
        },
        "hash": 15754410838997573272
    },
    "modules": [
        {
            "path": [
                "root"
            ],
            "outputs": {},
            "resources": {},
            "depends_on": []
        }
    ]
}

After Change it

{
    "version": 3,
    "serial": 0,
    "lineage": "15b3c30a-628a-4afe-84ec-9dedbd0c3f38",
    "backend": {
        "type": "s3",
        "config": {
            "bucket": "walter-devops-us-east-1",
            "encrypt": true,
            "key": "terraform/prod/terraform.tfstate",
            "region": "us-east-1"
        },
        "hash": 15754410838997573272
    },
    "modules": [
        {
            "path": [
                "root"
            ],
            "outputs": {},
            "resources": {},
            "depends_on": []
        }
    ]
}

Difference

10c10
<             "key": "terraform/dev/terraform.tfstate",
---
>             "key": "terraform/prod/terraform.tfstate",

Terraform Plan

~/git/terraform/bin/terraform plan

~/git/terraform-state/s3 master*
❯ ~/git/terraform/bin/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.

The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed. Cyan entries are data sources to be read.

Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.

+ aws_s3_bucket.w
    acceleration_status: "<computed>"
    acl:                 "private"
    arn:                 "<computed>"
    bucket:              "my_tf_test_bucket_w"
    bucket_domain_name:  "<computed>"
    force_destroy:       "false"
    hosted_zone_id:      "<computed>"
    region:              "<computed>"
    request_payer:       "<computed>"
    tags.%:              "2"
    tags.Environment:    "Dev"
    tags.Name:           "My bucket name"
    versioning.#:        "<computed>"
    website_domain:      "<computed>"
    website_endpoint:    "<computed>"


Plan: 1 to add, 0 to change, 0 to destroy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment