Skip to content

aws_batch_alpha: [object Object] in Cfn template synthetized image name with ECR image #25250

Closed
@diego-santacruz

Description

@diego-santacruz

Describe the bug

With the update to the new aws_batch_alpha API in 2.74 now using an ECR image synthetizes an incorrect image name in the JobDefinition: it has [object Object] instead of the intrinsic AWS::URLSuffix (i.e. amazonaws.com).

Expected Behavior

I expect the output of the code snippet below to be something like this

  "VideocvtJobCC7DC772": {
   "Type": "AWS::Batch::JobDefinition",
   "Properties": {
    "Type": "container",
    "ContainerProperties": {
     "Environment": [],
     "ExecutionRoleArn": {
      "Fn::GetAtt": [
       "VideocvtJobDefExecutionRole8D68368F",
       "Arn"
      ]
     },
     "Image": "123456789012.dkr.ecr.eu-central-1.amazonaws.com/name:my-tag",
     "ReadonlyRootFilesystem": false,
     "ResourceRequirements": [
      {
       "Type": "MEMORY",
       "Value": "4096"
      },
      {
       "Type": "VCPU",
       "Value": "1"
      }
     ]
    },
    "PlatformCapabilities": [
     "EC2"
    ],
    "RetryStrategy": {},
    "Timeout": {}
   },
   "Metadata": {
    "aws:cdk:path": "DevDSC/AryaBackendStateless/Videocvt/Job/Resource"
   }
  }

Or eventually with the following for Image above

       {
        "Fn::Join": [
         "",
         [
          "123456789012.dkr.ecr.eu-central-1.",
          {
           "Ref": "AWS::URLSuffix"
          },
          "/name:my-tag"
         ]
        ]
       }

Current Behavior

But the synthesis output is like this, note [object Object] in Image

  "VideocvtJobCC7DC772": {
   "Type": "AWS::Batch::JobDefinition",
   "Properties": {
    "Type": "container",
    "ContainerProperties": {
     "Environment": [],
     "ExecutionRoleArn": {
      "Fn::GetAtt": [
       "VideocvtJobDefExecutionRole8D68368F",
       "Arn"
      ]
     },
     "Image": "123456789012.dkr.ecr.eu-central-1.[object Object]/name:my-tag",
     "ReadonlyRootFilesystem": false,
     "ResourceRequirements": [
      {
       "Type": "MEMORY",
       "Value": "4096"
      },
      {
       "Type": "VCPU",
       "Value": "1"
      }
     ]
    },
    "PlatformCapabilities": [
     "EC2"
    ],
    "RetryStrategy": {},
    "Timeout": {}
   },
   "Metadata": {
    "aws:cdk:path": "DevDSC/AryaBackendStateless/Videocvt/Job/Resource"
   }
  }

Reproduction Steps

The following code snipped generated the faulty example above.

    const repo = ecr.Repository.fromRepositoryArn(this, 'Repo', 'arn:aws:ecr:eu-central-1:123456789012:repository/name');
    new batch.EcsJobDefinition(this, 'Job', {
      container: new batch.EcsEc2ContainerDefinition(this, 'JobDef', {
        image: ecs.ContainerImage.fromEcrRepository(repo, 'my-tag'),
        cpu: 1,
        memory: cdk.Size.gibibytes(4)
      })
    });

Possible Solution

No idea, but there seems to be a problem with the rendering of tokens.

Additional Information/Context

No response

CDK CLI Version

2.76

Framework Version

2.76

Node.js Version

v16.18.1

OS

Linux

Language

Typescript

Language Version

4.9.5

Other information

No response

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-batchRelated to AWS BatchbugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions