Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read back aws_launch_configuration's associate_public_ip_address field, to enable importing. #9399

Merged
merged 1 commit into from
Oct 17, 2016

Conversation

tomwilkie
Copy link
Contributor

I imported a aws_launch_configuration:

$ terraform  import -state=tfstate -var-file=tfvars module.infra.aws_launch_configuration.minions kubernetes_dev-minion-group-us-east-1a-c3.4xlarge

and wrote the respective config for it:

resource "aws_launch_configuration" "minions" {
    name = "${var.cluster_name}-minion-group-${var.availability_zone}-${var.minion_instance_type}"
    image_id = "${var.ami_id}"
    instance_type = "${var.minion_instance_type}"

    associate_public_ip_address = true

    ephemeral_block_device {
        virtual_name = "ephemeral0"
        device_name = "/dev/sdc"
    }

    ephemeral_block_device {
        virtual_name = "ephemeral1"
        device_name = "/dev/sdd"
    }

    ephemeral_block_device {
        virtual_name = "ephemeral2"
        device_name = "/dev/sde"
    }

    ephemeral_block_device {
        virtual_name = "ephemeral3"
        device_name = "/dev/sdf"
    }

    iam_instance_profile = "${aws_iam_instance_profile.minions.name}"

    key_name = "..."
}

But I would still see a diff when doing a terraform plan:

$ terraform plan -var-file=tfvars -state=tfstate -target=module.infra
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.

module.infra.aws_iam_role.minion: Refreshing state... (ID: kubernetes-minion)
module.infra.aws_iam_role.master: Refreshing state... (ID: kubernetes-master)
module.infra.aws_vpc_dhcp_options.main: Refreshing state... (ID: dopt-6468c300)
module.infra.aws_vpc.main: Refreshing state... (ID: vpc-a2a12fc5)
module.infra.aws_iam_instance_profile.minions: Refreshing state... (ID: kubernetes-minion)
module.infra.aws_iam_role_policy.minion: Refreshing state... (ID: kubernetes-minion:kubernetes-minion)
module.infra.aws_iam_role_policy.master: Refreshing state... (ID: kubernetes-master:kubernetes-master)
module.infra.aws_launch_configuration.minions: Refreshing state... (ID: kubernetes_dev-minion-group-us-east-1a-c3.4xlarge)
module.infra.aws_subnet.main: Refreshing state... (ID: subnet-d11a34fb)
module.infra.aws_security_group.masters: Refreshing state... (ID: sg-ec734797)
module.infra.aws_internet_gateway.gw: Refreshing state... (ID: igw-3ad5f85e)
module.infra.aws_security_group.minions: Refreshing state... (ID: sg-de7347a5)
module.infra.aws_network_acl.main: Refreshing state... (ID: acl-f8ef9d9f)
module.infra.aws_security_group_rule.masters-allow-https: Refreshing state... (ID: sgrule-2373692995)
module.infra.aws_security_group_rule.masters-allow-ssh: Refreshing state... (ID: sgrule-1130086772)
module.infra.aws_security_group_rule.masters-disallow-ingress: Refreshing state... (ID: sgrule-2300295140)
module.infra.aws_security_group_rule.masters-disallow-egress: Refreshing state... (ID: sgrule-3689494767)
module.infra.aws_autoscaling_group.minions: Refreshing state... (ID: kubernetes_dev-minion-group-us-east-1a)
module.infra.aws_security_group_rule.minions-disallow-ingress: Refreshing state... (ID: sgrule-1658975523)
module.infra.aws_security_group_rule.minions-disallow-egress: Refreshing state... (ID: sgrule-2533620319)
module.infra.aws_security_group_rule.minions-allow-ssh: Refreshing state... (ID: sgrule-3841135837)

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.

-/+ module.infra.aws_launch_configuration.minions
    associate_public_ip_address:                    "" => "true" (forces new resource)
    ebs_block_device.#:                             "0" => "<computed>"
    ebs_optimized:                                  "false" => "<computed>"
    enable_monitoring:                              "true" => "true"
    ephemeral_block_device.#:                       "4" => "4"
    ephemeral_block_device.1458338698.device_name:  "/dev/sde" => "/dev/sde"
    ephemeral_block_device.1458338698.virtual_name: "ephemeral2" => "ephemeral2"
    ephemeral_block_device.2690118092.device_name:  "/dev/sdd" => "/dev/sdd"
    ephemeral_block_device.2690118092.virtual_name: "ephemeral1" => "ephemeral1"
    ephemeral_block_device.3292514005.device_name:  "/dev/sdc" => "/dev/sdc"
    ephemeral_block_device.3292514005.virtual_name: "ephemeral0" => "ephemeral0"
    ephemeral_block_device.4064093701.device_name:  "/dev/sdf" => "/dev/sdf"
    ephemeral_block_device.4064093701.virtual_name: "ephemeral3" => "ephemeral3"
    iam_instance_profile:                           "kubernetes-minion" => "kubernetes-minion"
    image_id:                                       "ami-08ee2f65" => "ami-08ee2f65"
    instance_type:                                  "c3.4xlarge" => "c3.4xlarge"
    key_name:                                       "..." => "..."
    name:                                           "kubernetes_dev-minion-group-us-east-1a-c3.4xlarge" => "kubernetes_dev-minion-group-us-east-1a-c3.4xlarge"
    root_block_device.#:                            "1" => "<computed>"


Plan: 1 to add, 1 to destroy.

This PR fixes that.

@catsby
Copy link
Contributor

catsby commented Oct 17, 2016

Thanks @tomwilkie ! The tests pass and I tried out some scenarios myself, so I'll pull this in

TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSLaunchConfiguration_ -timeout 120m
=== RUN   TestAccAWSLaunchConfiguration_importBasic
--- PASS: TestAccAWSLaunchConfiguration_importBasic (7.63s)
=== RUN   TestAccAWSLaunchConfiguration_basic
--- PASS: TestAccAWSLaunchConfiguration_basic (12.33s)
=== RUN   TestAccAWSLaunchConfiguration_withBlockDevices
--- PASS: TestAccAWSLaunchConfiguration_withBlockDevices (8.48s)
=== RUN   TestAccAWSLaunchConfiguration_withSpotPrice
--- PASS: TestAccAWSLaunchConfiguration_withSpotPrice (7.33s)
=== RUN   TestAccAWSLaunchConfiguration_withVpcClassicLink
--- PASS: TestAccAWSLaunchConfiguration_withVpcClassicLink (19.20s)
=== RUN   TestAccAWSLaunchConfiguration_withIAMProfile
--- PASS: TestAccAWSLaunchConfiguration_withIAMProfile (19.15s)
=== RUN   TestAccAWSLaunchConfiguration_withEncryption
--- PASS: TestAccAWSLaunchConfiguration_withEncryption (8.57s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    82.710s
Test:

@catsby
Copy link
Contributor

catsby commented Oct 17, 2016

(the failing travis tests are unrelated)

@catsby catsby merged commit 08c5d2a into hashicorp:master Oct 17, 2016
@tomwilkie tomwilkie deleted the read-aws-launch-config-public-ip branch October 17, 2016 14:13
@tomwilkie
Copy link
Contributor Author

Thanks!

@ghost
Copy link

ghost commented Apr 21, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 21, 2020
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants