You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your request related to a new offering from AWS?
no
Is your request related to a problem? Please describe.
I'm creating the lambda and it's main layer through terraform but want to update it via aws cli in ci/cd. Once a pipeline is done. Terraform wants to change back the layer version of the function. Is there a way to prevent this?
Also what is the best practice here? Is there a better way to update the lambda and it's layer via seperate ci/cd than aws cli?
I don't want to have to run our whole infrastructure code in terraform for each code change in any of the lambda's.
Describe the solution you'd like.
Make the module able to do the first create but ignore any changes afterwards.
Additional context
##################################################### S3 Bucket####################################################module"s3_bucket" {
source="terraform-aws-modules/s3-bucket/aws"bucket="devops-${var.environment}-${var.function_name}"acl="private"force_destroy=true
}
resource"aws_s3_bucket_object""lambda" {
bucket=module.s3_bucket.s3_bucket_idkey="${var.function_name}-main.zip"source="${path.module}/dummy_lambda.zip"lifecycle {
ignore_changes=[
tags_all
]
}
}
resource"aws_s3_bucket_object""layer" {
bucket=module.s3_bucket.s3_bucket_idkey="${var.function_name}-layer.zip"source="${path.module}/dummy_layer.zip"lifecycle {
ignore_changes=[
tags_all
]
}
}
##################################################### Security Group####################################################module"lambda_security_group" {
source="terraform-aws-modules/security-group/aws"version="~> 4.0"name="lambda-sg-${var.environment}-${var.function_name}"description="Lambda security group for function ${var.function_name}"vpc_id=var.vpc_vpc_idcomputed_ingress_with_source_security_group_id=[
{
rule ="http-80-tcp"
source_security_group_id = var.api_gateway_security_group_security_group_id
}
]
number_of_computed_ingress_with_source_security_group_id=1egress_rules=["all-all"]
}
##################################################### Lambda Function (building locally, storing on S3,# set allowed triggers, set policies)####################################################module"lambda_function" {
source="terraform-aws-modules/lambda/aws"function_name="${var.environment}-${var.function_name}"description=var.function_descriptionhandler=var.handlerruntime=var.runtimepublish=truememory_size=var.memory_sizecreate_package=falses3_existing_package={
bucket = module.s3_bucket.s3_bucket_id
key = aws_s3_bucket_object.lambda.id
}
layers=[
module.lambda_layer_s3.lambda_layer_arn,
]
environment_variables=var.environment_variablesvpc_subnet_ids=var.vpc_private_subnetsvpc_security_group_ids=[module.lambda_security_group.security_group_id]
attach_network_policy=trueattach_cloudwatch_logs_policy=trueattach_tracing_policy=truecloudwatch_logs_retention_in_days=7cloudwatch_logs_tags=merge(var.tags, {
lambda ="${var.environment}-${var.function_name}"
})
allowed_triggers={
AllowExecutionFromAPIGateway = {
service ="apigateway"
source_arn ="${var.api_gateway_apigatewayv2_api_execution_arn}/*/*"
}
}
tags=var.tags
}
################################ Lambda Layer (storing on S3)###############################module"lambda_layer_s3" {
source="terraform-aws-modules/lambda/aws"create_layer=truelayer_name="${var.environment}-${var.function_name}-layer"description="Lambda layer for function ${var.function_name})"compatible_runtimes=[var.runtime]
create_package=falses3_existing_package={
bucket = module.s3_bucket.s3_bucket_id
key = aws_s3_bucket_object.layer.id
}
}
The text was updated successfully, but these errors were encountered:
your configuration looks ok, but probably you are going to have the same problem mentioned here because the TF will try to replace your function deployed using your CD.
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.
Is your request related to a new offering from AWS?
no
Is your request related to a problem? Please describe.
I'm creating the lambda and it's main layer through terraform but want to update it via aws cli in ci/cd. Once a pipeline is done. Terraform wants to change back the layer version of the function. Is there a way to prevent this?
Also what is the best practice here? Is there a better way to update the lambda and it's layer via seperate ci/cd than aws cli?
I don't want to have to run our whole infrastructure code in terraform for each code change in any of the lambda's.
Describe the solution you'd like.
Make the module able to do the first create but ignore any changes afterwards.
Additional context
The text was updated successfully, but these errors were encountered: