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.74k stars 9.1k forks source link

[Docs]: aws_codedeploy_deployment_group->ecs_service only take ONE #27478

Open FransUrbo opened 1 year ago

FransUrbo commented 1 year ago

Documentation Link

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group#ecs_service

Description

ecs_service - (Optional) Configuration block(s) of the ECS services for a deployment group (documented below).

This say block(s) (plural!), however only one block is allowed.

References

Error: Too many ecs_service blocks

  on <file> line 63, in resource "aws_codedeploy_deployment_group" "codedeploy":
  63:   content {

No more than 1 "ecs_service" blocks are allowed

This with the following code:

variable "cluster" {
    description                         = "Container cluster information"
    type                                = object({
        arn             = string
        name            = string
        service         = list(string)
        service_arn     = list(string)
    })
}

resource "aws_codedeploy_deployment_group" "codedeploy" {
    [...]
    dynamic "ecs_service" {
        for_each        = var.cluster.service
        content {
            cluster_name                = var.cluster.name
            service_name                = ecs_service.value
        }
    }

And then set var.cluster.service to multiple values.

Would you like to implement a fix?

No response

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

FransUrbo commented 1 year ago

Looking at the AWS documentation, it seems the documentation is correct, but the code is not. Or... I'm a bit confused on how to interpret the AWS documentation..

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-deploymentgroup.html#cfn-codedeploy-deploymentgroup-ecsservices

Type: List of ECSService

FransUrbo commented 1 year ago

Terraform v1.3.3 aws v4.36.1

kurbar commented 1 year ago

This is a provider bug. You can configure multiple ECS services to a deployment group but currently the AWS provider does not allow it.

A workaround is to use the aws_cloudformation_stack resource and create CodeDeploy resources through CloudFormation.