hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.77k stars 9.13k forks source link

AutoPublishAlias Feature for Lambda Alias #15433

Open sairajputh88 opened 4 years ago

sairajputh88 commented 4 years ago

Current Terraform Version

0.11.14

Use-cases

To overcome the cold start with Lambdas, trying to configure Provisioned concurrency to Lambda with version and alias.

when the Lambda code changes the version bumps up with ‘publish’ option. Have to pass the newly published Lambda version to Lambda Alias every time statically.

Looking for an option to automatically point a Lambda Alias to newly published Lambda version through TF.

Attempted Solutions

From below snippet, I am able to point to a Lambda version x.

resource "aws_lambda_alias" "test_alias" {
  name             = "testalias"
  description      = "a sample description"
  function_name    = aws_lambda_function.test_lambda.function_name
  function_version = "2"
}

I tried as below but it points to $LATEST.

resource "aws_lambda_alias" "carma_party_id_function_cold_start" {
  name = "testalias"
  function_name = aws_lambda_function.test_lambda.function_name
  function_version = aws_lambda_function.test_lambda.version
  description = "a sample description"
}

Where as the provisioned concurrency is only compatible with version and alias.

Proposal

There is some thing in Cloud Formation which make it possible as per AWS Support. Which is 'AutoPublishAlias', which creates an alias with a name that you provided and points to the updated version of the Lambda function. Please find the below reference.

References

AutoPublishAlias reference

QueryGSIFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: target/Sample-api-SNAPSHOT.jar
Handler: com.org.project.lambdas.QueryHandler::handleRequest
Runtime: java8
AutoPublishAlias: newtest
# Creates and publishes an updated version of that function with the latest code.
# Creates an alias with a name that you provided and points to the updated version of the Lambda function
DeploymentPreference:
Type: AllAtOnce # All traffic is shifted from the original Lambda function to the updated Lambda function version at once.
ProvisionedConcurrencyConfig:
ProvisionedConcurrentExecutions: 1
Role: arn:aws:iam::123456789012:role/my-role
Environment:
Variables:
REGION: !Ref AWS::Region
h3ct0rjs commented 2 years ago

Is there any update on this feature ? What's the best approach to implement this using terraform?

Manouchehri commented 1 year ago

Same question here. Would be good to have DeploymentPreference as well.

wenqiglantz commented 1 year ago

Requesting this feature as well in Terraform to mimic CloudFormation's AutoPublishAlias.

h3ct0rjs commented 1 year ago

Hi,

Just curious, this has been here for a long time, is this in the backlog?

Best Regards, H

yazeedalrubyli commented 2 months ago

Can you take care of this please.