Hi,
I set up an autoscaling group with launch configuration, with an application loadbalancer. This part works like a charm.
Then I created a codedeployment configuration with following code:
resource "aws_iam_instance_profile" "test_profile" {
name = "${var.organization}-iam-coded-profile"
role = aws_iam_role.coded-role.name
}
resource "aws_iam_role" "coded-role" {
name = "${var.organization}-coded-role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "codedeploy.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
EOF
}
resource "aws_iam_role_policy_attachment" "AWSCodeDeployRole" {
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSCodeDeployRole"
role = aws_iam_role.coded-role.name
}
resource "aws_codedeploy_deployment_config" "be-coded-config" {
deployment_config_name = "${var.organization}-be-coded-config"
minimum_healthy_hosts {
type = "HOST_COUNT"
value = 1
}
}
resource "aws_codedeploy_app" "be-coded-app" {
compute_platform = "Server"
name = "${var.organization}-be-coded-app"
}
resource "aws_codedeploy_deployment_group" "be-coded-group" {
app_name = aws_codedeploy_app.be-coded-app.name
deployment_group_name = "${var.organization}-be-coded-group"
service_role_arn = aws_iam_role.coded-role.arn
deployment_config_name = aws_codedeploy_deployment_config.be-coded-config.id
autoscaling_groups = [aws_autoscaling_group.be-asg.name]
load_balancer_info {
target_group_info {
name = aws_lb_target_group.be-lb-targetgroup.name
}
}
deployment_style {
deployment_option = "WITHOUT_TRAFFIC_CONTROL"
deployment_type = "IN_PLACE"
}
auto_rollback_configuration {
enabled = true
events = ["DEPLOYMENT_FAILURE"]
}
}
But whenever I try to deploy to the CodeDeploy group I get following error:
2021-08-25 20:58:30 ERROR [codedeploy-agent(943)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Missing credentials - please check if this instance was started with an IAM instance profile
I have been unable to find what I’m missing.
Can somebody maybe help me out on this?
Kind regards,
Lowie