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

r/aws_launch_configuration: support security groups and user data for import #2800

Conversation

loivis
Copy link
Contributor

@loivis loivis commented Dec 28, 2017

Fix #2648 .

Noticed that ClassicLinkVPCSecurityGroups is also returned as []*string like SecurityGroups. So the same change is applied on both.

@jen20 jen20 added the enhancement Requests to existing resources that expand the functionality or scope. label Dec 29, 2017
@bflad bflad added the service/autoscaling Issues and PRs that pertain to the autoscaling service. label Jan 28, 2018
@bflad bflad added bug Addresses a defect in current functionality. and removed enhancement Requests to existing resources that expand the functionality or scope. labels Apr 9, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this @loivis 😄

Can you please add acceptance testing to ensure the behavior is correct? It can be as simple as adding the below import TestStep to TestAccAWSLaunchConfiguration_withVpcClassicLink and removing user_data from the ignore list in TestAccAWSLaunchConfiguration_importBasic

{
  ResourceName: "aws_launch_configuration.foo",
  ImportState: true,
  ImportStateVerify: true,
},

d.Set("associate_public_ip_address", lc.AssociatePublicIpAddress)
if len(lc.SecurityGroups) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified and error checked with:

if err := d.Set("security_groups", flattenStringList(lc.SecurityGroups)); err != nil {
  return fmt.Errorf("error setting security_groups: %s", err)
}

}
d.Set("security_groups", securityGroups)
}
if *lc.UserData != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should safely dereference this pointer or it can cause a panic: if aws.StringValue(lc.UserData) !=""


d.Set("vpc_classic_link_id", lc.ClassicLinkVPCId)
d.Set("vpc_classic_link_security_groups", lc.ClassicLinkVPCSecurityGroups)
if len(lc.ClassicLinkVPCSecurityGroups) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified and error checked with:

if err := d.Set("vpc_classic_link_security_groups", flattenStringList(lc.ClassicLinkVPCSecurityGroups)); err != nil {
  return fmt.Errorf("error setting vpc_classic_link_security_groups: %s", err)
}

@loivis loivis force-pushed the 2648-import-launch-configuration-with-user-data-and-security-groups branch from 9ba43de to f9eac46 Compare April 9, 2018 18:42
@ghost ghost added the size/S Managed by automation to categorize the size of a PR. label Apr 9, 2018
@bflad bflad added this to the v1.14.1 milestone Apr 9, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are awesome, @loivis! LGTM 🚀

10 tests passed (all tests)
=== RUN   TestAccAWSLaunchConfiguration_withSpotPrice
--- PASS: TestAccAWSLaunchConfiguration_withSpotPrice (6.62s)
=== RUN   TestAccAWSLaunchConfiguration_withEncryption
--- PASS: TestAccAWSLaunchConfiguration_withEncryption (9.20s)
=== RUN   TestAccAWSLaunchConfiguration_importBasic
--- PASS: TestAccAWSLaunchConfiguration_importBasic (9.55s)
=== RUN   TestAccAWSLaunchConfiguration_withBlockDevices
--- PASS: TestAccAWSLaunchConfiguration_withBlockDevices (12.76s)
=== RUN   TestAccAWSLaunchConfiguration_withVpcClassicLink
--- PASS: TestAccAWSLaunchConfiguration_withVpcClassicLink (18.54s)
=== RUN   TestAccAWSLaunchConfiguration_basic
--- PASS: TestAccAWSLaunchConfiguration_basic (22.09s)
=== RUN   TestAccAWSLaunchConfiguration_updateRootBlockDevice
--- PASS: TestAccAWSLaunchConfiguration_updateRootBlockDevice (22.58s)
=== RUN   TestAccAWSLaunchConfiguration_ebs_noDevice
--- PASS: TestAccAWSLaunchConfiguration_ebs_noDevice (24.58s)
=== RUN   TestAccAWSLaunchConfiguration_updateEbsBlockDevices
--- PASS: TestAccAWSLaunchConfiguration_updateEbsBlockDevices (24.84s)
=== RUN   TestAccAWSLaunchConfiguration_withIAMProfile
--- PASS: TestAccAWSLaunchConfiguration_withIAMProfile (28.17s)

@bflad bflad merged commit aba7629 into hashicorp:master Apr 9, 2018
bflad added a commit that referenced this pull request Apr 9, 2018
@loivis loivis deleted the 2648-import-launch-configuration-with-user-data-and-security-groups branch April 10, 2018 06:58
@bflad
Copy link
Contributor

bflad commented Apr 11, 2018

This has been released in version 1.14.1 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@bflad
Copy link
Contributor

bflad commented Apr 17, 2018

The user_data portion of this may have caused unexpected behavior, see: #4197

@ghost
Copy link

ghost commented Apr 6, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service. size/S Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Imported aws_launch_configuration does not include security groups and userdata.
3 participants