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

!Ref to local path not supported for AWS::Serverless::LayerVersion #4767

Open
hoffa opened this issue Feb 25, 2023 · 1 comment
Open

!Ref to local path not supported for AWS::Serverless::LayerVersion #4767

hoffa opened this issue Feb 25, 2023 · 1 comment
Labels
area/intrinsics Ref, If, Sub, GetAtt, ...

Comments

@hoffa
Copy link
Contributor

hoffa commented Feb 25, 2023

Description:

See aws/serverless-application-model#2533 (comment) and linked issues for context.

Given the following template where CodePath is a local path:

Transform: AWS::Serverless-2016-10-31
Parameters:
  CodePath:
    Type: String
Resources:
  MyLayerVersion:
    Type: AWS::Serverless::LayerVersion
    Properties:
      ContentUri: !Ref CodePath

Deployment fails:

Resource with id [MyLayerVersion0a209abe4f] is invalid. 'ContentUri' requires Bucket and Key properties to be specified.

Steps to reproduce:

sam init --name sam-app --runtime python3.8 --dependency-manager pip --app-template hello-world
cd sam-app

Replace template.yaml with:

Transform: AWS::Serverless-2016-10-31
Parameters:
  CodePath:
    Type: String
Resources:
  MyLayerVersion:
    Type: AWS::Serverless::LayerVersion
    Properties:
      ContentUri: !Ref CodePath

Deploy:

sam build --parameter-overrides CodePath=hello_world/
sam deploy --guided --parameter-overrides CodePath=hello_world/

Observed result:

The template passed to the SAM transform is the following (i.e. doesn't include the packaged assets):

Transform: AWS::Serverless-2016-10-31
Parameters:
  CodePath:
    Type: String
Resources:
  MyLayerVersion:
    Type: AWS::Serverless::LayerVersion
    Properties:
      ContentUri:
        Ref: CodePath
    Metadata:
      SamResourceId: MyLayerVersion

However, with CodeUri in AWS::Serverless::Function, the following template is deployable and the assets are packaged as expected:

Transform: AWS::Serverless-2016-10-31
Parameters:
  CodePath:
    Type: String
Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: !Ref CodePath
      Handler: app.lambda_handler
      Runtime: python3.9

Expected result:

Expected !Ref to work with local paths, similar to CodeUri.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: macOS
  2. sam --version: SAM CLI, version 1.72.0
  3. AWS region: us-west-2
{
  "version": "1.72.0",
  "system": {
    "python": "3.8.16",
    "os": "macOS-13.2.1-x86_64-i386-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "Not available",
    "aws_cdk": "1.101.0 (build 149f0fc)",
    "terraform": "1.3.7"
  }
}

Add --debug flag to command you are running

@hoffa hoffa added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Feb 25, 2023
@hoffa hoffa changed the title Support !Ref to local path for AWS::Serverless::LayerVersion !Ref to local path not supported for AWS::Serverless::LayerVersion Feb 25, 2023
@sriram-mv sriram-mv added area/intrinsics Ref, If, Sub, GetAtt, ... and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Feb 27, 2023
@sriram-mv
Copy link
Contributor

Tagging as area/intrinsics. We should create a parent ticket for all intrinsic issues and link it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/intrinsics Ref, If, Sub, GetAtt, ...
Projects
None yet
Development

No branches or pull requests

2 participants