Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(aws-sam): ContentUri in LayerVersion does not support S3 bucket/key #12413

Closed
jamesls opened this issue Jan 7, 2021 · 2 comments
Closed

(aws-sam): ContentUri in LayerVersion does not support S3 bucket/key #12413

jamesls opened this issue Jan 7, 2021 · 2 comments
Assignees
Labels
@aws-cdk/aws-sam Related to AWS Serverless Application Model bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@jamesls
Copy link
Member

jamesls commented Jan 7, 2021

The ContentUri for AWS::Serverless::LayerVersion requires the value to be a string in the CDK (https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_sam/CfnLayerVersion.html), but the spec allows it also be an S3 Location.

Property Name Type Description
ContentUri string | S3 Location Object Required. S3 Uri or location for the layer code.

This is due to the SAM schema the CDK uses missing this additional type. This has now been fixed upstream (awslabs/goformation#339), but the PR to pull in this change into the CDK was closed (#12370). Can we get that PR reopened and merged?

Reproduction Steps

Create an aws_sam.CfnLayerVersion object. The content URI must be a string.

What did you expect to happen?

I'd like to be able to specify an S3 bucket and key (in my case I'm using aws_s3_assets.Asset)

What actually happened?

If you manually try to override this and provide your own s3 bucket/key you'll get a validation error as you'd expect because the schema doesn't support this.

  Error: Resolution error: Supplied properties not correct for "CfnLayerVersionProps"
    contentUri: {"Bucket":{"Ref":"AssetParameters59ed3761e0090e8d958742734d21a2470d6d8232f489fc7a13b7c391e1e259ccS3Bucket4BD22AB4"},"Key":{"Fn::Join":["",[{"Fn::Select":[0,{"Fn::Split":["||",{"Ref":"AssetParameters59ed3761e0090e8d958742734d21a2470d6d8232f489fc7a13b7c391e1e259ccS3VersionKeyB8AFB4C8"}]}]},{"Fn::Select":[1,{"Fn::Split":["||",{"Ref":"AssetParameters59ed3761e0090e8d958742734d21a2470d6d8232f489fc7a13b7c391e1e259ccS3VersionKeyB8AFB4C8"}]}]}]]}} should be a string.
      at ValidationResult.assertSuccess (/private/var/folders/rb/4c1d0xbd18g_wxjcjlvb0whn1cjh5m/T/jsii-kernel-ym3ebW/node_modules/@aws-cdk/core/lib/runtime.js:137:19)
      at cfnLayerVersionPropsToCloudFormation (/private/var/folders/rb/4c1d0xbd18g_wxjcjlvb0whn1cjh5m/T/jsii-kernel-ym3ebW/node_modules/@aws-cdk/aws-sam/lib/sam.generated.js:2864:47)
      at CfnLayerVersion.renderProperties (/private/var/folders/rb/4c1d0xbd18g_wxjcjlvb0whn1cjh5m/T/jsii-kernel-ym3ebW/node_modules/@aws-cdk/aws-sam/lib/sam.generated.js:2959:16)
      at PostResolveToken.ret.Resources [as processor] (/private/var/folders/rb/4c1d0xbd18g_wxjcjlvb0whn1cjh5m/T/jsii-kernel-ym3ebW/node_modules/@aws-cdk/core/lib/cfn-resource.js:291:52)
      at PostResolveToken.postProcess (/private/var/folders/rb/4c1d0xbd18g_wxjcjlvb0whn1cjh5m/T/jsii-kernel-ym3ebW/node_modules/@aws-cdk/core/lib/util.js:81:21)
      at Object.postProcess (/private/var/folders/rb/4c1d0xbd18g_wxjcjlvb0whn1cjh5m/T/jsii-kernel-ym3ebW/node_modules/@aws-cdk/core/lib/private/resolve.js:31:82)
      at DefaultTokenResolver.resolveToken (/private/var/folders/rb/4c1d0xbd18g_wxjcjlvb0whn1cjh5m/T/jsii-kernel-ym3ebW/node_modules/@aws-cdk/core/lib/resolvable.js:55:38)
      at resolve (/private/var/folders/rb/4c1d0xbd18g_wxjcjlvb0whn1cjh5m/T/jsii-kernel-ym3ebW/node_modules/@aws-cdk/core/lib/private/resolve.js:100:33)
      at Object.resolve (/private/var/folders/rb/4c1d0xbd18g_wxjcjlvb0whn1cjh5m/T/jsii-kernel-ym3ebW/node_modules/@aws-cdk/core/lib/private/resolve.js:29:33)
      at resolve (/private/var/folders/rb/4c1d0xbd18g_wxjcjlvb0whn1cjh5m/T/jsii-kernel-ym3ebW/node_modules/@aws-cdk/core/lib/private/resolve.js:118:43)

Environment

  • **CDK CLI Version :1.83.0 (build 827c5f4)
  • **Framework Version:1.83.0 (build 827c5f4)
  • **Node.js Version:v14.13.0
  • **OS :macOS
  • **Language (Version):Python 3.9

This is 🐛 Bug Report

@jamesls jamesls added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 7, 2021
@NGL321 NGL321 changed the title aws_sam: ContentUri in LayerVersion does not support S3 bucket/key (aws-sam): ContentUri in LayerVersion does not support S3 bucket/key Jan 28, 2021
@github-actions github-actions bot added the @aws-cdk/aws-sam Related to AWS Serverless Application Model label Jan 28, 2021
@njlynch
Copy link
Contributor

njlynch commented Feb 8, 2021

#12370 was closed, as it was superseded by #12490, which was merged in and released as part of v1.85.0. If you update, you should be able to assign an S3Location as the ContentURI.

@njlynch njlynch closed this as completed Feb 8, 2021
@github-actions
Copy link

github-actions bot commented Feb 8, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-sam Related to AWS Serverless Application Model bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants