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

Creating dynamically named aws_lambda_alias results in badness #108

Closed
hashibot opened this issue Jun 13, 2017 · 5 comments
Closed

Creating dynamically named aws_lambda_alias results in badness #108

hashibot opened this issue Jun 13, 2017 · 5 comments
Labels
bug Addresses a defect in current functionality. service/lambda Issues and PRs that pertain to the lambda service.
Milestone

Comments

@hashibot
Copy link

This issue was originally opened by @dansteen as hashicorp/terraform#5664. It was migrated here as part of the provider split. The original body of the issue is below.


Hey!

I created an aws_lambda_alias with a dynamic name:

resource "aws_lambda_alias" "assessment-trait-scores-scaler" {
        name = "${consul_keys.assessment-trait-scores-scaler.var.version}"
        description = "Git Hash ${consul_keys.assessment-trait-scores-scaler.var.version}"
        function_name = "${aws_lambda_function.assessment-trait-scores-scaler.arn}"
        function_version = "$LATEST"
}

The intention was to have an alias named after the git hash of the jar being generated. This would create a new alias each time the jar is updated (I realize there are some issues with this - this was an early exploration). Unfortunately, I get the following error after the first run:

* aws_lambda_alias.assessment-trait-scores-scaler: ResourceNotFoundException: Cannot find alias arn: arn:aws:lambda:us-east-1:xxxxxxx
:function:assessment-trait-scores-scaler-prod:ae91e35ffdc42c614fad63983d39ff5f21ff2fb1

Which is true, but not at all what I expected. I expected it to remove the old alias, and create a new one, rather than attempting to "update" the new alias (which doesn't exist yet). To resole this, I had to manually delete the entries out of the state file.

Thanks!
Dan

@hashibot hashibot added the bug Addresses a defect in current functionality. label Jun 13, 2017
@edmundcraske
Copy link
Contributor

Just came across a similar thing where we rebuilt an environment and the alias resource was to be repointed to a different function_name - it looks like the 'name' and 'function_name' arguments need to have ForceNew set to true.

@radeksimko radeksimko added the service/lambda Issues and PRs that pertain to the lambda service. label Jan 25, 2018
@gerovermaas
Copy link

Hi,

I'm still experiencing this problem:

1 error(s) occurred:

* module.data_lake_postgres.aws_lambda_alias.git_branch_alias: 1 error(s) occurred:

* aws_lambda_alias.git_branch_alias: Error updating Lambda alias: ResourceNotFoundException: Alias not found: arn:aws:lambda:eu-west-1:958773302171:function:sandbox-lake-postgres:testbranch2
        status code: 404, request id: 0303ecba-3cc6-11e8-ac11-5f68bb9331a4

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

And the terraform code is:

resource "aws_lambda_alias" "git_branch_alias" {
  name             = "${var.git_branch}"
  function_name    = "${aws_lambda_function.lambda_func.arn}"
  function_version = "${aws_lambda_function.lambda_func.version}"
}

When I switch branches and do a terraform apply the above error occurs.

Reading the previous comment I see that ForceNew has been set of the name but not for the function_name (see https://github.com/terraform-providers/terraform-provider-aws/blob/6512d8fbbdd394398b49ffc9b516dda16f8bc9a3/aws/resource_aws_lambda_alias.go#L37)

Any plans to resolve this?

I'm using aws provider version 1.9.

Thanks,
Gero

@simonvanderveldt
Copy link
Contributor

It seems like this has been fixed by #4106

@bflad
Copy link
Contributor

bflad commented Jul 2, 2018

Setting ForceNew on the name attribute was previously released in version 1.14.1 of the AWS provider and has been available in all releases since. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

If there are other lingering issues here, please create new issues following the issue template and we'll troubleshoot further. Thanks!

@bflad bflad closed this as completed Jul 2, 2018
@bflad bflad added this to the v1.14.1 milestone Jul 2, 2018
@ghost
Copy link

ghost commented Apr 4, 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 4, 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/lambda Issues and PRs that pertain to the lambda service.
Projects
None yet
Development

No branches or pull requests

6 participants