Skip to content

Tagging in the fargate-v2 component leads to failure if no AWS::ElasticLoadBalancingV2::TargetGroup is used #24

@petlitskiy

Description

@petlitskiy

The tagging in your current fargate-v2 component works like next:

  1. first appearance:
    Name: help-site (from fargate-v2, assigned to AWS::ECS::Service)
  2. second appearance:
    {Fn::Sub: "Name", Fn::Sub: "help-site"} (from ecs-task, assigned to AWS::ECS::TaskDefinition, but there is already defined { Key: "Name", Value: external_parameters[:component_name] })

All these lead to failure (duplicated tags):

  Task:
    Type: AWS::ECS::TaskDefinition
    Properties:
    ...
      Tags:
      - Key: Name
        Value: helpsiteTask
      - Key: Environment
        Value:
          Ref: EnvironmentName
      - Key: EnvironmentType
        Value:
          Ref: EnvironmentType
      - Key:
          Fn::Sub: Name
        Value:
          Fn::Sub: help-site
  EcsFargateService:
    Type: AWS::ECS::Service
    Properties:
      LaunchType: FARGATE
      Tags:
      - Key: Environment
        Value:
          Ref: EnvironmentName
      - Key: EnvironmentType
        Value:
          Ref: EnvironmentType
      - Key:
          Fn::Sub: Name
        Value:
          Fn::Sub: help-site

We can remove the tag to avoid tag duplication in AWS::ECS::TaskDefinition, but in this case the AWS::ECS::Service loses the Name tag:

  EcsFargateService:
    Type: AWS::ECS::Service
    Properties:
      LaunchType: FARGATE
      Tags:
      - Key: Environment
        Value:
          Ref: EnvironmentName
      - Key: EnvironmentType
        Value:
          Ref: EnvironmentType

And we cannot use the @aws-sdk/client-resource-groups-tagging-api to find out the needed ECS task by tag Name in this case (when no needs on targetGroup).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions