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

feat(serverless): add AWS::Serverless::Application to CFN spec #1634

Merged
merged 8 commits into from
Feb 5, 2019

Conversation

sam-goodwin
Copy link
Contributor

@sam-goodwin sam-goodwin commented Jan 29, 2019

Fixes #1602

This change adds support for deploying serverless applications from SAR as part of a CDK application:

Example usage:

const app = new cdk.App();
const stack = new cdk.Stack(app, 'serverless');

const processor = new lambda.Function(stack, 'Function', {
  code: lambda.Code.inline('exports.handler = async (event) => console.log(event)'),
  handler: 'index.handler',
  runtime: lambda.Runtime.NodeJS810
});

new CfnApplication(stack, 'App', {
  location: {
    applicationId: 'arn:aws:serverlessrepo:us-east-1:077246666028:applications/aws-serverless-twitter-event-source',
    semanticVersion: '2.0.0'
  },
  parameters: {
    SearchText: '#serverless -filter:nativeretweets',
    TweetProcessorFunctionName: processor.functionName
  }
});

Pull Request Checklist

  • Testing
    • Unit test added
    • CLI change?: coordinate update of integration tests with team
    • cdk-init template change?: coordinated update of integration tests with team
  • Docs
    • jsdocs: All public APIs documented
    • README: README and/or documentation topic updated
  • Title and Description
    • Change type: title prefixed with fix, feat will appear in changelog
    • Title: use lower-case and doesn't end with a period
    • Breaking?: last paragraph: "BREAKING CHANGE: <describe what changed + link for details>"
    • Issues: Indicate issues fixed via: "Fixes #xxx" or "Closes #xxx"
  • Sensitive Modules (requires 2 PR approvers)
    • IAM Policy Document (in @aws-cdk/aws-iam)
    • EC2 Security Groups and ACLs (in @aws-cdk/aws-ec2)
    • Grant APIs (only if not based on official documentation with a reference)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.

@eladb
Copy link
Contributor

eladb commented Feb 4, 2019

@sam-goodwin any updates?

Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Maybe you can write a small unit test in the @aws-cdk/aws-serverless library that plays with this L1 a little bit?

Copy link

@jlhood jlhood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this!

@sam-goodwin
Copy link
Contributor Author

I tested this and it synthesizes "fine", but it doesn't add the Transform to the template so cdk deploy fails. The toolkit needs to detect use of SAM resources and apply the transform.

@sam-goodwin
Copy link
Contributor Author

Ah, it needs "RequiredTransform": "AWS::Serverless-2016-10-31" to be set.

@sam-goodwin
Copy link
Contributor Author

sam-goodwin commented Feb 5, 2019

Fixed the transform but then ran into:

4/5 | 22:34:47 | CREATE_FAILED | AWS::CloudFormation::Stack | App Requires capabilities : [CAPABILITY_AUTO_EXPAND]

Also, goformation has been updated with the missing resources: awslabs/goformation#163, but the spec is actually wrong. I submitted a PR with a fix: awslabs/goformation#166

Copy @PaulMaddox

@sam-goodwin sam-goodwin merged commit bfa40b1 into master Feb 5, 2019
@sam-goodwin sam-goodwin deleted the samgood/serverless-app branch February 5, 2019 23:23
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

Successfully merging this pull request may close these issues.

Support AWS::Serverless::Application as a CDK Construct
3 participants