Skip to content

(aws-ecs): fromFargateServiceAttributes() using serviceArn does not return correct serviceName #16634

@qinjie

Description

@qinjie

When I use fromFargateServiceAttributes() to import an existing FargateService, its returned object doesn't has correct fargate service name if I use serviceArn as attribute, whereas passing serviceName attribute to the function returns object with correct service name.

Reproduction Steps

    const importedFargateService =
      ecs.FargateService.fromFargateServiceAttributes(
        this,
        "imported-fargate-service",
        {
          // serviceArn: cdk.Fn.importValue(
          //   `${this.project_code}-FargateServiceArn`
          // ),
          //serviceName: cdk.Fn.importValue(
          //  `${this.project_code}-FargateServiceName`
          //),
          cluster: importedCluster,
        }
      );

    new cdk.CfnOutput(this, "importedFargateServiceName", {
      value: importedFargateService.serviceName,
    });

    new cdk.CfnOutput(this, "importedFargateServiceArn", {
      value: importedFargateService.serviceArn,
    });

    new cdk.CfnOutput(this, "importedFargateClusterName", {
      value: importedFargateService.cluster.clusterName,
    });

    new cdk.CfnOutput(this, "importedFargateClusterArn", {
      value: importedFargateService.cluster.clusterArn,
    });

What did you expect to happen?

CloudFormation outputs should give correct FargateService name.
image

What actually happened?

FargateService name is the same as cluster name.
image

Environment

  • **CDK CLI Version : 1.122.0 **
  • Framework Version: aws-cli/2.2.6 Python/3.8.8 Windows/10 exe/AMD64 prompt/off
  • Node.js Version: 14.17.0
  • OS : Windows 10
  • **Language (Version): TypeScript (4.3.5) **

This is 🐛 Bug Report

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ecsRelated to Amazon Elastic ContainerbugThis issue is a bug.effort/mediumMedium work item – several days of effortin-progressThis issue is being actively worked on.p1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions