|
1 | | -## AWS Serverless Codepipeline Serverlessrepo Publish |
| 1 | +## AWS Serverless Codepipeline Serverlessrepo Publish  |
2 | 2 |
|
3 | 3 | This is a serverless app that publishes applications to AWS Serverless Application Repository. This app creates a Lambda function that a user could then use as an Invoke action target in their CodePipeline. |
4 | 4 |
|
| 5 | +## Architecture |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +1. App has a single Lambda function ServerlessRepoPublish lambda. |
| 10 | +1. ServerlessRepoPublish lambda is invoked by CodePipeline as part of the Invoke Action of a pipeline. |
| 11 | +1. ServerlessRepoPublish lambda is passed the S3 URL of the packaged SAM template in the CodePipeline S3 bucket. |
| 12 | +1. ServerlessRepoPublish lambda downloads the template and parses its Metadata to get application information for calls to CreateApplication/UpdateApplication. |
| 13 | +1. ServerlessRepoPublish lambda then does the create or update job processor logic: |
| 14 | + 1. Call [AcknowledgeJob](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_AcknowledgeJob.html) API to claim the job. |
| 15 | + 1. Read SAM template and parse application metadata. |
| 16 | + 1. Call [CreateApplication](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/applications.html) API with metadata and pass SAM template with semantic version from template metadata. |
| 17 | + 1. If success, call [PutJobSuccessResult](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_PutJobSuccessResult.html) |
| 18 | + 1. If application already exists |
| 19 | + 1. Call [GetApplication](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/applications-applicationid.html) - Application ARN can be parsed from the 4xx error message. NOTE: This isn't the cleanest solution, but it doesn't require an API change to SAR. |
| 20 | + 1. Call [UpdateApplication](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/applications-applicationid.html) if any metadata has changed |
| 21 | + 1. Call [CreateApplicationVersion](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/applications-applicationid-versions-semanticversion.html) with SAM template. If it already exists, do nothing. |
| 22 | + 1. If API calls fail for any other reason, call [PutJobFailureResult](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_PutJobFailureResult.html) with failure details. |
| 23 | + |
5 | 24 | ## License Summary |
6 | 25 |
|
7 | 26 | This sample code is made available under the MIT license. |
0 commit comments