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

provider/aws: Added Lambda Environment configuration (supersedes #10255) #10275

Merged
merged 2 commits into from
Nov 21, 2016

Conversation

catsby
Copy link
Member

@catsby catsby commented Nov 21, 2016

Continues #10255 with some touchups, namely environment wasn't being read. I also encountered an issue where the API would return an "empty" vpc config, so now we filter those out instead of populating the state with an empty config, triggering a ForceNew.

@Ninir please take a look!

TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSLambdaFunction_en -timeout 120m
=== RUN   TestAccAWSLambdaFunction_envVariables
--- PASS: TestAccAWSLambdaFunction_envVariables (33.15s)
=== RUN   TestAccAWSLambdaFunction_encryptedEnvVariables
--- PASS: TestAccAWSLambdaFunction_encryptedEnvVariables (72.76s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	105.929s

log.Printf("[INFO] Setting Lambda %s VPC config %#v from API", d.Id(), config)
vpcSetErr := d.Set("vpc_config", config)
if vpcSetErr != nil {
return fmt.Errorf("Failed setting vpc_config: %s", vpcSetErr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you share the config you used to find that please? thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

it was really weird, I never specified the vpc config, but if I had env vars specified, then removed one in the AWS web UI, my next plan showed a diff because VPC config was coming back "empty"

Ex config: https://gist.github.com/catsby/f3dcc08f936db041ea52263bccba83b9

It's fixed here though so I doubt you'll see it

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh got it! good catch :)
(I would have use my own PR to reproduce, but still, thanks!)

Copy link
Member Author

Choose a reason for hiding this comment

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

Example DEBUG output of said empty vpc:

2016/11/21 17:03:41 [DEBUG] plugin: terraform-provider-aws: Function:
2016/11/21 17:03:41 [DEBUG] plugin: terraform-provider-aws: {
2016/11/21 17:03:41 [DEBUG] plugin: terraform-provider-aws:   CodeSha256: "Ux/n9CP8l+7Ht0tICw0QPs0yLdC1b+1nJ9K5MZR9ENw=",
					[ ... ]
2016/11/21 17:03:41 [DEBUG] plugin: terraform-provider-aws:   Role: "arn:aws:iam::187416307283:role/cts-iam-lambda",
2016/11/21 17:03:41 [DEBUG] plugin: terraform-provider-aws:   Runtime: "nodejs",
2016/11/21 17:03:41 [DEBUG] plugin: terraform-provider-aws:   Timeout: 3,
2016/11/21 17:03:41 [DEBUG] plugin: terraform-provider-aws:   Version: "$LATEST",
2016/11/21 17:03:41 [DEBUG] plugin: terraform-provider-aws:   VpcConfig: {
2016/11/21 17:03:41 [DEBUG] plugin: terraform-provider-aws:     SecurityGroupIds: [],
2016/11/21 17:03:41 [DEBUG] plugin: terraform-provider-aws:     SubnetIds: [],
2016/11/21 17:03:41 [DEBUG] plugin: terraform-provider-aws:     VpcId: ""
2016/11/21 17:03:41 [DEBUG] plugin: terraform-provider-aws:   }
2016/11/21 17:03:41 [DEBUG] plugin: terraform-provider-aws: }

Only happens if I edit the ENV vars in the Web ui (in this case I added one)

Copy link
Member Author

Choose a reason for hiding this comment

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

(I would have use my own PR to reproduce, but still, thanks!)

You still can! The only way I could reproduce is if I had 2+ env vars specified in config, and then used the web UI to remove one of them. Then my next plan would show the ForceNew diff as well as the config diff

envSetErr = d.Set("environment", []interface{}{})
} else {
envSetErr = d.Set("environment", flattenLambdaEnvironment(function.Environment.Variables))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I forgot this part... Newbie mistake... 👍

@Ninir
Copy link
Contributor

Ninir commented Nov 21, 2016

Thanks for the help and review on this, learned a lot as a newcomer :)

@catsby
Copy link
Member Author

catsby commented Nov 21, 2016

Tests after a small refactor:

TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSLambdaFunction_en -timeout 120m
=== RUN   TestAccAWSLambdaFunction_envVariables
--- PASS: TestAccAWSLambdaFunction_envVariables (28.22s)
=== RUN   TestAccAWSLambdaFunction_encryptedEnvVariables
--- PASS: TestAccAWSLambdaFunction_encryptedEnvVariables (61.75s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	89.986s
Test:

merging, thanks @Ninir !

@catsby catsby merged commit 8df5a9d into master Nov 21, 2016
@catsby catsby deleted the pr-10255 branch November 21, 2016 23:13
@kwilczynski
Copy link
Contributor

@catsby @Ninir - are you going to update this PR with changes discussed from the other one? I don't want things from there to get lost :) Apologies!

@catsby
Copy link
Member Author

catsby commented Nov 22, 2016

@kwilczynski I'm not aware of them, and this PR has already been merged :/ can you open a new issue? Or new PR?

@ghost
Copy link

ghost commented Apr 19, 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 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants