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

Not possible to have CodeUri as a parameter #61

Closed
Pelto opened this issue Jan 13, 2017 · 6 comments
Closed

Not possible to have CodeUri as a parameter #61

Pelto opened this issue Jan 13, 2017 · 6 comments

Comments

@Pelto
Copy link

Pelto commented Jan 13, 2017

For some reason, it doesn't seem possible to specify CodeUri as a parameter.

I have a template that specifies a function:

AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: A hello world application.
Parameters:
  CodeUri:
    Type: String
    Description: The link to the code to use.
Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs4.3
      CodeUri: !Ref CodeUri

When I try to execute the template using aws cloudformation deploy the following error appears:

aws cloudformation deploy --stack-name example --template-file lambda-example.sam.yaml --parameter-overrides CodeUri=s3://$BUCKET_NAME/example.zip

Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [HelloWorldFunction] is invalid. 'CodeUri' is not a valid S3 Uri of the form "s3://bucket/key" with optional versionId query parameter.

I tried running it with the --debug flag attached and it looks like the correct S3 Uri is added. Below is an extract from the debug output:

    <Parameters>
      <member>
        <ParameterKey>CodeUri</ParameterKey>
        <ParameterValue>s3://johannes-lambda-test/example.zip</ParameterValue>
      </member>
    </Parameters>

The example code that have been used can be found at https://github.com/Pelto/aws-serverless-2016-10-31-bug

@mikeshutlar
Copy link

I'm seeing the same with Join:

CodeUri: !Join [ "", [ "s3://", !Ref LambdaS3BucketName, "/example.zip" ] ]
 'CodeUri' is not a valid S3 Uri of the form "s3://bucket/key" with optional versionId query parameter. 

@sanathkr
Copy link
Contributor

Yeah, this isn't supported yet. See #22

@matsev
Copy link

matsev commented May 12, 2017

CloudFormation parameters have been enabled for CodeUri. However, you must specify values for Bucket and Key separately, e.g.

CodeUri:
      Bucket: !Ref BucketName
      Key: !Ref CodeKey

See the Using Intrinsic Functions paragraph in the SAM documentation for more information.

@areichman
Copy link

If the bucket and key are specified using a !Ref in this way, it appears there is no longer any way for aws cloudformation package to create a new zip bundle and transform the SAM template on its own. Is that correct?

Are there any workarounds that would allow packaging to continue in the absence of any CodeUri-related parameters? I was trying something like this to remove the Bucket and Key attributes without any luck:

CodeUri:
  Bucket: !If [RequiresPackage, !Ref "AWS::NoValue", !Ref CodeUriBucket]
  Key: !If [RequiresPackage, !Ref "AWS::NoValue", !Ref CodeUriKey]

@red8888
Copy link

red8888 commented Jan 15, 2020

Is there some weird divergence between the different components of Cloudformation, because I can leave CodeUri blank and its deploys without issue, but if I try to create a ChangeSet I see this error:

"Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [Func] is invalid. Either 'InlineCode' or 'CodeUri' must be set"
So are ChangeSets just not compatible with SAM at all?

@keetonian
Copy link
Contributor

@red8888 how were you deploying before? Was it with the SAM or AWS CLI?

hawflau added a commit to hawflau/serverless-application-model that referenced this issue Nov 5, 2020
* docs: fix link to all_policy_templates example file (aws#1682)

* fix: Enhance CompatibleRuntimes property of AWS::Serverless::LayerVersion (aws#1683)

* Adding Tracing property to State Machine resource (aws#1697)

* Step Functions: Adding support for X-Ray tracing

* Renaming TracingConfiguration to Tracing

Co-authored-by: Vaib Suri <[email protected]>

* add new arguments to allow vpc/vpce endpoints as intrinsics (aws#1689)

* add new arguments to allow vpc/vpce endpoints as intrinsics

* Add more unit tests

* Add more test cases, and code changes according to comments.

* Fix: Updated Slack Invite Link (aws#1712)

* Updated Slack Invite Link

* Restricted jsonschema to Python 2

* Forced pyrsistent to 0.16 in Python 2

* Reverted Changes to enum34

* Merge master back to develop (aws#1734)

* Release v1.26.0 (aws#1680)

* feat: add support for VPCEndpointIds in EndpointConfiguration

* fix: update formatting with black

* docs: update 2016-10-31.md

* docs: added api endpointconfiguration example

* docs: make example more generic

* fix: remove nested EndpointConfiguration types from output

* fix: only allow one EndpointConfiguration Type

* doc: update example to reflect only allowing one EndpointConfiguration
Type

* fix : missing UserPool properties (aws#1506) (aws#1581)

* fix: resource policy generation for {path+} (aws#1580)

* refactor: Remove 2016-10-31 examples

* update PR template

* adjust pr template

* Adding authorization scopes as list validation in ApiGatewayAuthorizer (v1 and v2). (aws#1670)

* Adding authorization scopes as list validation in ApiGatewayAuthorizer and ApiGatewayV2Authorizer.

* make black.

* Adding functional test for invalid auth scope.

* adding error condition for invalid test.

* removing test template file.

* feat: MSK event type support for AWS::Serverless::Function (aws#52)

Co-authored-by: Steve Brown <[email protected]>
Co-authored-by: jtaylor00 <[email protected]>
Co-authored-by: Jacob Fuss <[email protected]>
Co-authored-by: Alex Wood <[email protected]>
Co-authored-by: Tarun <[email protected]>

* Update __init__.py (aws#1704)

* Release/v1.27.0 resolveconflict (aws#1717)

* Release v1.26.0 (aws#1680)

* feat: add support for VPCEndpointIds in EndpointConfiguration

* fix: update formatting with black

* docs: update 2016-10-31.md

* docs: added api endpointconfiguration example

* docs: make example more generic

* fix: remove nested EndpointConfiguration types from output

* fix: only allow one EndpointConfiguration Type

* doc: update example to reflect only allowing one EndpointConfiguration
Type

* fix : missing UserPool properties (aws#1506) (aws#1581)

* fix: resource policy generation for {path+} (aws#1580)

* refactor: Remove 2016-10-31 examples

* update PR template

* adjust pr template

* Adding authorization scopes as list validation in ApiGatewayAuthorizer (v1 and v2). (aws#1670)

* Adding authorization scopes as list validation in ApiGatewayAuthorizer and ApiGatewayV2Authorizer.

* make black.

* Adding functional test for invalid auth scope.

* adding error condition for invalid test.

* removing test template file.

* feat: MSK event type support for AWS::Serverless::Function (aws#52)

Co-authored-by: Steve Brown <[email protected]>
Co-authored-by: jtaylor00 <[email protected]>
Co-authored-by: Jacob Fuss <[email protected]>
Co-authored-by: Alex Wood <[email protected]>
Co-authored-by: Tarun <[email protected]>

* Fix: Updated Slack Invite Link (aws#1712)

* Updated Slack Invite Link

* Restricted jsonschema to Python 2

* Forced pyrsistent to 0.16 in Python 2

* Reverted Changes to enum34

Co-authored-by: Sriram Madapusi Vasudevan <[email protected]>
Co-authored-by: Steve Brown <[email protected]>
Co-authored-by: jtaylor00 <[email protected]>
Co-authored-by: Jacob Fuss <[email protected]>
Co-authored-by: Alex Wood <[email protected]>
Co-authored-by: Tarun <[email protected]>
Co-authored-by: Cosh_ <[email protected]>

Co-authored-by: Sriram Madapusi Vasudevan <[email protected]>
Co-authored-by: Steve Brown <[email protected]>
Co-authored-by: jtaylor00 <[email protected]>
Co-authored-by: Jacob Fuss <[email protected]>
Co-authored-by: Alex Wood <[email protected]>
Co-authored-by: Tarun <[email protected]>
Co-authored-by: Mehmet Nuri Deveci <[email protected]>
Co-authored-by: Cosh_ <[email protected]>

* Lambdaauth (aws#1733)

* Add support for Lambda Authorizers in HttpAPI

* Address comments and fix formatting

* fix version

* Validate input parameters. Update tests

* black reformat

Co-authored-by: Raymond Wang <[email protected]>

* Feature toggle (aws#1737)

* Adding logic to pipe app config providers. Unit test pending

* Adding some documentation to config providers.

* Adding some unit tests and making black ignore json files.

* minor cleanup.

* Addressing PR comments.

* feature: Support MTLS auth properties in REST and HTTP API domain names (aws#1725)

* feature: Support MTLS auth properties in REST and HTTP API domain names

* fix unicode != str issue in py2.7

* add SecurityPolicy because default RESTAPI is using TLS1.0

* Add new property DisableExecuteApiEndpoint

* black reformat

* Address comments

* Add tests on invalid templates

* address test failures in py2.7

* restart travis tests

* fix: adding support for passing target id to EventBridgeRule (aws#1747)

* Manage black version using requirement file (aws#1748)

* chore: Manage black version in dev.txt

- config pre-commit
- config development guide
- config travis

Refer to the commit below in aws-sam-cli
aws/aws-sam-cli@d725db5fbfc698a9f0c7582

* Format using black 20.8b1

* Opt-out black fron dev.txt for Python 2

Co-authored-by: Patrick Greenwell <[email protected]>
Co-authored-by: Raymond Wang <[email protected]>
Co-authored-by: vaib-amz <[email protected]>
Co-authored-by: Vaib Suri <[email protected]>
Co-authored-by: Cosh_ <[email protected]>
Co-authored-by: Sriram Madapusi Vasudevan <[email protected]>
Co-authored-by: Steve Brown <[email protected]>
Co-authored-by: jtaylor00 <[email protected]>
Co-authored-by: Jacob Fuss <[email protected]>
Co-authored-by: Alex Wood <[email protected]>
Co-authored-by: Tarun <[email protected]>
Co-authored-by: Mehmet Nuri Deveci <[email protected]>
Co-authored-by: Tolledo <[email protected]>
Co-authored-by: _sam <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants