Open Samith88 opened 2 years ago
Is anyone has any thought on this? If anyone can share their thoughts that will be great..
Hey @Samith88 👋 Thank you for taking the time to raise this! Based on the information that you provided, I did a bit of digging, and something caught my eye. You mentioned you're using EC2, but the document that you linked to regarding targetGroupPairInfo
states that this is used for ECS deployments:
Information about two target groups and how traffic is routed during an Amazon ECS deployment.
It looks like you instead need loadBalancerInfo
-> targetGroupInfo
or elbInfo
. This seems to be backed up by the following AWS document: Create a deployment group for an EC2/On-Premises blue/green deployment.
Hi @justinretzolk,
Thanks for the valuable response.
Yes, I have put a EC2 aws doc regarding blue/green just to have an idea. Sorry if that misleading.
Basically my requirement is to have a live traffic path and test traffic path (active and inactive listeners) with EC2 B/G deployments. Anyway I will check this doc and thanks for sharing that.
how do i create a trigger to run lambda at before the code deploy and one at the success of the code deploy. via terraform
resource "aws_codedeploy_app" "codedeploy_group" {
name = "asg-practice-cda-use1"
}
resource "aws_codedeploy_deployment_group" "codedeploy_group" {
app_name = "asg-practice-cda-use1"
deployment_group_name = "asg-practice-cdg-use1"
service_role_arn = "arn:aws:iam::70773643480:role/AWSCodeDeployRole"
auto_rollback_configuration {
enabled = false
}
deployment_style {
deployment_option = "WITH_TRAFFIC_CONTROL"
deployment_type = "IN_PLACE"
}
dynamic load_balancer_info {
for_each = "${local.elb_exists}"
content {
target_group_info {
name = "asg-practice-web-asg-use1"
}
}
}
autoscaling_groups = ["asg-practice-web-asg-use1"]
deployment_config_name = "CodeDeployDefault.AllAtOnce"
trigger_configuration {
trigger_events = ["DeploymentStart"]
trigger_name = "lambda-pre-trigger"
trigger_target_arn = aws_lambda_function.lambda-pre.arn
# trigger_target_type = "Lambda"
}
trigger_configuration {
trigger_events = ["DeploymentSuccess"]
trigger_name = "lambda-post-trigger"
trigger_target_arn = aws_lambda_function.lambda-post.arn
# trigger_target_type = "Lambda"
}
}
data "archive_file" "zip_the_python_code-pre" {
type = "zip"
source_file = "${path.module}/lambda-pre.py"
output_path = "./lambda-pre.zip"
}
resource "aws_lambda_function" "lambda-pre" {
filename = "./lambda-pre.zip"
# s3_bucket = "asg-trial/asg/"
function_name = "asg-pre"
role = "arn:aws:iam::70773643480:role/service-role/asg-trial-role-snmtxqyq"
handler = "lambda_function"
runtime = "python3.9"
# source_code_hash = filebase64sha256("./lambda-pre.py")
timeout = 900
}
data "archive_file" "zip_the_python_code-post" {
type = "zip"
source_file = "${path.module}/lambda-post.py"
output_path = "./lambda-post.zip"
}
resource "aws_lambda_function" "lambda-post" {
filename = "./lambda-post.zip"
# s3_bucket = "asg-trial/asg/"
function_name = "asg-post-t"
role = "arn:aws:iam::70773643480:role/service-role/asg-trial-role-snmtxqyq"
handler = "lambda_function"
runtime = "python3.9"
source_code_hash = filebase64sha256("./lambda-post.py")
timeout = 900
}
this gives error on terraform apply
╷
│ Error: updating CodeDeploy deployment group (082e3f7f-6284-421c-b392-c04207787295): InvalidTriggerConfigException: Topic ARN arn:aws:lambda:ap-southeast-2:70773643480:function:asg-pre is not valid
I need create an aws codedeploy deployment group for Blue/Green deployments with EC2 using cdktf. My code for codedeploy deployment group as follows,
But when I'm trying to deploy this, I'm getting following error,
But as per my code, I'm passing target groups for create this object.
Also, noticed that in aws docs we have loadBalancerInfo -> targetGroupPairInfo -> targetGroups which is not available in cdktf package(CodedeployDeploymentGroupConfig).
Ref: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codedeploy-deploymentgroup-targetgrouppairinfo.html
I Have ran cdktf by enabling trace logs, so the response and request I got as follows,
Request for codedeploy,
Response for codedeploy,
Some environment details,
For further information you can refer this issue which I was created in terraform-cdk repo.