Skip to content

Commit 7c712ed

Browse files
committed
fix: added chnages to replace codecommit with Github in all the sam projects in serverless samples repo
1 parent 006fb61 commit 7c712ed

17 files changed

Lines changed: 122 additions & 208 deletions

File tree

fargate-rest-api/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ There are various blog posts and code examples for serverless APIs available, ho
1010
- API access logging as part of SAM templates
1111
- business specific metrics
1212

13-
Examples are (loosely) based on a [SpaceFinder project](https://github.com/amazon-archives/aws-serverless-auth-reference-app). The services used by this application include Amazon API Gateway, Amazon Cognito, AWS Lambda, Amazon ECS, AWS Fargate, and Amazon DynamoDB. The CI/CD pipelines use AWS CodePipeline, AWS CodeCommit, and AWS CodeBuild.
13+
Examples are (loosely) based on a [SpaceFinder project](https://github.com/amazon-archives/aws-serverless-auth-reference-app). The services used by this application include Amazon API Gateway, Amazon Cognito, AWS Lambda, Amazon ECS, AWS Fargate, and Amazon DynamoDB. The CI/CD pipelines use AWS CodePipeline, and AWS CodeBuild.
1414

1515
## Architecture
1616

fargate-rest-api/javascript-rest-nlb-ecs-sam/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The application uses a Amazon Cognito stack for authentication/authorization and
2727
- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html): `aws --version` (Use 2.x)
2828
- [Node.js](https://nodejs.org/en/download/): `node --version` (Use 22.x)
2929
- [GitHub account](https://github.com/signup/)
30-
- [GitHub empty repository](hhttps://github.com/new/)
30+
- [GitHub empty repository](https://github.com/new/)
3131
- [GitHub personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic/)
3232

3333
## Deploying with CI/CD pipeline

queue-based-ingestion/python-sam/README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ This project contains source code and supporting files for a serverless applicat
1818

1919
The application uses a shared Amazon Cognito stack for authentication/authorization. You will need to create this stack and update `template.yaml` parameters section with the stack name. See the next section for details.
2020

21+
## Prerequisites
22+
- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html): `aws --version` (Use 2.x)
23+
- [GitHub account](https://github.com/signup/)
24+
- [GitHub empty repository](https://github.com/new/)
25+
- [GitHub personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic/)
26+
2127
## Amazon Cognito Setup
2228

2329
This example uses a shared stack that deploys Amazon Cognito resources. The shared stack will be deployed automatically if you use a CI/CD pipeline. See [README.md](../shared/README.md) in the shared resources directory for the stack manual deployment instructions. After manual deployment finishes, update your AWS SAM template file `template.yaml` parameter CognitoStackName with the shared Cognito stack name.
@@ -158,24 +164,23 @@ git init -b main
158164
git pull ../serverless-samples queue-based-ingestion
159165
cd python-sam
160166
```
161-
162-
To create the pipeline, you will need to run the following command:
167+
If you changed stack name, make sure that Parameters section of template.yaml is updated with the output values from the shared Cognito stack
168+
To push the code in GitHub repository, run the following commands (with the desired URL (i.e. HTTPS, SSH) in place of `<GitHub_Repository_URL>`):
163169

164170
```bash
165-
aws cloudformation create-stack --stack-name queue-based-ingestion-cicd --template-body file://pipeline.yaml --capabilities CAPABILITY_IAM
166-
171+
git remote add origin <GitHub_Repository_URL>
172+
git push origin main
167173
```
168174

169-
The pipeline will attempt to run and will fail at the SourceCodeRepo stage as there is no code in the AWS CodeCommit yet.
170-
171-
**Note:** You may need to set up AWS CodeCommit repository access for HTTPS users [using Git credentials](https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-gc.html?icmpid=docs_acc_console_connect_np) and [set up the AWS CLI Credential Helper](https://docs.aws.amazon.com/console/codecommit/connect-tc-alert-np).
172-
173-
Once you have access to the code repository, navigate to python-sam folder, and, if you changed stack name, make sure that Parameters section of template.yaml is updated with the output values from the shared Cognito stack, and push code base to CodeCommit to start automated deployments.
174-
You can find URL to AWS CodeCommit Repository in the output section of the CloudFormation stack deployed above.
175+
To create the pipeline, you will need to run the following command:
175176

176177
```bash
177-
git remote add origin <URL to AWS CodeCommit repository>
178-
git push origin main
178+
aws cloudformation create-stack --stack-name queue-based-ingestion-cicd --template-body file://pipeline.yaml --capabilities CAPABILITY_IAM --parameter-overrides \
179+
gitHubOwner=<GITHUB_OWNER> \
180+
gitHubRepo=<GITHUB_REPOSITORY_NAME> \
181+
gitHubBranch=<GITHUB_BRANCH_NAME> \
182+
gitHubToken=<GITHUB_PERSONAL_ACCESS_TOKEN>
183+
179184
```
180185

181186
Navigate to the AWS CodePipeline in AWS Management Console and release this change if needed by clicking "Release change" button.

queue-based-ingestion/python-sam/pipeline.yaml

Lines changed: 18 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ Description: >
66
This template generates a 2-environment CI/CD Pipeline for Queue-based ingestion with API Gateway application
77
Based on https://github.com/aws-samples/cookiecutter-aws-sam-pipeline
88
9+
Parameters:
10+
gitHubOwner:
11+
Type: String
12+
gitHubRepo:
13+
Type: String
14+
gitHubBranch:
15+
Type: String
16+
gitHubToken:
17+
Type: String
18+
919
Resources:
10-
CodeRepository:
11-
Type: AWS::CodeCommit::Repository
12-
Properties:
13-
RepositoryName: !Ref AWS::StackName
14-
RepositoryDescription: Code repository for API Gateway queue based ingestion sample
1520

1621
# S3 Bucket for build artifacts
1722
BuildArtifactsBucket:
@@ -47,7 +52,7 @@ Resources:
4752
Environment:
4853
Type: LINUX_CONTAINER
4954
ComputeType: BUILD_GENERAL1_SMALL
50-
Image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
55+
Image: aws/codebuild/amazonlinux2-x86_64-standard:5.0
5156
EnvironmentVariables:
5257
- Name: BUILD_OUTPUT_BUCKET
5358
Value: !Ref BuildArtifactsBucket
@@ -72,7 +77,7 @@ Resources:
7277
Environment:
7378
Type: LINUX_CONTAINER
7479
ComputeType: BUILD_GENERAL1_SMALL
75-
Image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
80+
Image: aws/codebuild/amazonlinux2-x86_64-standard:5.0
7681
EnvironmentVariables:
7782
- Name: TEST_APPLICATION_STACK_NAME
7883
Value: !Sub ${AWS::StackName}-testing
@@ -100,12 +105,14 @@ Resources:
100105
- Name: SourceCodeRepo
101106
ActionTypeId:
102107
Category: Source
103-
Owner: AWS
104-
Provider: CodeCommit
108+
Owner: ThirdParty
109+
Provider: GitHub
105110
Version: "1"
106111
Configuration:
107-
RepositoryName: !GetAtt CodeRepository.Name
108-
BranchName: main
112+
Owner: !Ref gitHubOwner
113+
Repo: !Ref gitHubRepo
114+
Branch: !Ref gitHubBranch
115+
OAuthToken: !Ref gitHubToken
109116
OutputArtifacts:
110117
- Name: SourceCodeAsZip
111118
RunOrder: 1
@@ -444,7 +451,6 @@ Resources:
444451
Path: /
445452
ManagedPolicyArns:
446453
- arn:aws:iam::aws:policy/AWSCodePipeline_FullAccess
447-
- arn:aws:iam::aws:policy/AWSCodeCommitReadOnly
448454
Policies:
449455
- PolicyName: CodePipelineAccess
450456
PolicyDocument:
@@ -465,40 +471,6 @@ Resources:
465471
- "s3:ListBucket"
466472
- "s3:*Object*"
467473
Resource: !Sub "arn:aws:s3:::${BuildArtifactsBucket}/*"
468-
- Effect: Allow
469-
Action:
470-
- "codecommit:GitPull"
471-
- "codecommit:EvaluatePullRequestApprovalRules"
472-
- "codecommit:UploadArchive"
473-
- "codecommit:GetBlob"
474-
- "codecommit:GetBranch"
475-
- "codecommit:GetComment"
476-
- "codecommit:GetCommentReactions"
477-
- "codecommit:GetCommentsForComparedCommit"
478-
- "codecommit:GetCommentsForPullRequest"
479-
- "codecommit:GetCommit"
480-
- "codecommit:GetDifferences"
481-
- "codecommit:GetFile"
482-
- "codecommit:GetFolder"
483-
- "codecommit:GetMergeCommit"
484-
- "codecommit:GetMergeOptions"
485-
- "codecommit:GetObjectIdentifier"
486-
- "codecommit:GetPullRequest"
487-
- "codecommit:GetPullRequestApprovalStates"
488-
- "codecommit:GetReferences"
489-
- "codecommit:GetRepository"
490-
- "codecommit:GetRepositoryTriggers"
491-
- "codecommit:GetTree"
492-
- "codecommit:GetUploadArchiveStatus"
493-
- "codecommit:ListBranches"
494-
- "codecommit:ListPullRequests"
495-
- "codecommit:ListRepositories"
496-
- "codecommit:ListTagsForResource"
497-
- "codecommit:BatchGetCommits"
498-
- "codecommit:BatchGetRepositories"
499-
- "codecommit:BatchDescribeMergeConflicts"
500-
501-
Resource: !Sub "arn:aws:codecommit:${AWS::Region}:${AWS::AccountId}:${CodeRepository.Name}"
502474
- PolicyName: CodePipelineCodeBuildAndCloudformationAccess
503475
PolicyDocument:
504476
Version: "2012-10-17"
@@ -528,13 +500,6 @@ Resources:
528500
- !Sub "arn:aws:cloudformation:${AWS::Region}:aws:transform/Serverless-2016-10-31"
529501

530502
Outputs:
531-
CodeCommitRepositoryHttpUrl:
532-
Description: AWS CodeCommit Git repository
533-
Value: !GetAtt CodeRepository.CloneUrlHttp
534-
535-
CodeCommitRepositorySshUrl:
536-
Description: AWS CodeCommit Git repository
537-
Value: !GetAtt CodeRepository.CloneUrlSsh
538503

539504
BuildArtifactS3Bucket:
540505
Description: Amazon S3 Bucket for Pipeline and Build artifacts

serverless-graphql-api/javascript-appsync-sam-js/pipeline.yaml

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ Description: >
66
This template generates a 2-environment CI/CD Pipeline for sample serverless API application
77
Based on https://github.com/aws-samples/cookiecutter-aws-sam-pipeline
88
9+
Parameters:
10+
gitHubOwner:
11+
Type: String
12+
gitHubRepo:
13+
Type: String
14+
gitHubBranch:
15+
Type: String
16+
gitHubToken:
17+
Type: String
18+
919
Resources:
10-
CodeRepository:
11-
Type: AWS::CodeCommit::Repository
12-
Properties:
13-
RepositoryName: !Ref AWS::StackName
14-
RepositoryDescription: Code repository for serverless GraphQL API sample application
1520

1621
# S3 Bucket for build artifacts
1722
BuildArtifactsBucket:
@@ -43,7 +48,7 @@ Resources:
4348
Environment:
4449
Type: LINUX_CONTAINER
4550
ComputeType: BUILD_GENERAL1_SMALL
46-
Image: aws/codebuild/amazonlinux2-x86_64-standard:4.0
51+
Image: aws/codebuild/amazonlinux2-x86_64-standard:5.0
4752
EnvironmentVariables:
4853
- Name: BUILD_OUTPUT_BUCKET
4954
Value: !Ref BuildArtifactsBucket
@@ -69,7 +74,7 @@ Resources:
6974
Environment:
7075
Type: LINUX_CONTAINER
7176
ComputeType: BUILD_GENERAL1_SMALL
72-
Image: aws/codebuild/amazonlinux2-x86_64-standard:4.0
77+
Image: aws/codebuild/amazonlinux2-x86_64-standard:5.0
7378
EnvironmentVariables:
7479
- Name: TEST_APPLICATION_STACK_NAME
7580
Value: !Sub ${AWS::StackName}-Testing
@@ -98,12 +103,14 @@ Resources:
98103
- Name: SourceCodeRepo
99104
ActionTypeId:
100105
Category: Source
101-
Owner: AWS
102-
Provider: CodeCommit
106+
Owner: ThirdParty
107+
Provider: GitHub
103108
Version: "1"
104109
Configuration:
105-
RepositoryName: !GetAtt CodeRepository.Name
106-
BranchName: main
110+
Owner: !Ref gitHubOwner
111+
Repo: !Ref gitHubRepo
112+
Branch: !Ref gitHubBranch
113+
OAuthToken: !Ref gitHubToken
107114
OutputArtifacts:
108115
- Name: SourceCodeAsZip
109116
RunOrder: 1
@@ -450,7 +457,6 @@ Resources:
450457
Path: /
451458
ManagedPolicyArns:
452459
- arn:aws:iam::aws:policy/AWSCodePipeline_FullAccess
453-
- arn:aws:iam::aws:policy/AWSCodeCommitReadOnly
454460
Policies:
455461
- PolicyName: CodePipelineAccess
456462
PolicyDocument:
@@ -471,17 +477,6 @@ Resources:
471477
- "s3:ListBucket"
472478
- "s3:*Object*"
473479
Resource: !Sub "arn:aws:s3:::${BuildArtifactsBucket}/*"
474-
- Effect: Allow
475-
Action:
476-
- "codecommit:GitPull"
477-
- "codecommit:Get*"
478-
- "codecommit:List*"
479-
- "codecommit:BatchGet*"
480-
- "codecommit:BatchDescribe*"
481-
- "codecommit:Describe*"
482-
- "codecommit:EvaluatePullRequestApprovalRules"
483-
- "codecommit:UploadArchive"
484-
Resource: !Sub "arn:aws:codecommit:${AWS::Region}:${AWS::AccountId}:${CodeRepository.Name}"
485480
- PolicyName: CodePipelineCodeBuildAndCloudformationAccess
486481
PolicyDocument:
487482
Version: "2012-10-17"
@@ -511,13 +506,6 @@ Resources:
511506
- !Sub "arn:aws:cloudformation:${AWS::Region}:aws:transform/Serverless-2016-10-31"
512507

513508
Outputs:
514-
CodeCommitRepositoryHttpUrl:
515-
Description: AWS CodeCommit Git repository
516-
Value: !GetAtt CodeRepository.CloneUrlHttp
517-
518-
CodeCommitRepositorySshUrl:
519-
Description: AWS CodeCommit Git repository
520-
Value: !GetAtt CodeRepository.CloneUrlSsh
521509

522510
BuildArtifactS3Bucket:
523511
Description: Amazon S3 Bucket for Pipeline and Build artifacts

serverless-graphql-api/javascript-appsync-sam-vtl/README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ This project contains source code and supporting files for a serverless applicat
1414

1515
The application uses a shared Amazon Cognito stack for authentication/authorization. The shared stack will be deployed automatically if you use the CI/CD pipeline included in this project. If you deploy the application manually, you will need to create this stack and update the `template.yaml` parameters section with the stack name. See the manual deployment section for more details.
1616

17+
## Prerequisites
18+
- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html): `aws --version` (Use 2.x)
19+
- [GitHub account](https://github.com/signup/)
20+
- [GitHub empty repository](https://github.com/new/)
21+
- [GitHub personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic/)
22+
1723
## Deploy the CI/CD pipeline
1824
To create the CI/CD pipeline, we will copy the code from the serverless-samples directory into a new and separate directory and use this new directory as the codebase for your pipeline.
1925

@@ -26,23 +32,22 @@ serverless-graphql-api-cicd:~$ git init -b main
2632
serverless-graphql-api-cicd:~$ git pull ../serverless-samples serverless-graphql-api
2733
serverless-graphql-api-cicd:~$ cd javascript-appsync-sam-vtl
2834
```
35+
If you changed stack name, make sure that Parameters section of template.yaml is updated with the output values from the shared Amazon Cognito stack
36+
To push the code in GitHub repository, run the following commands (with the desired URL (i.e. HTTPS, SSH) in place of `<GitHub_Repository_URL>`):
2937

30-
To create the pipeline, run the following command:
31-
32-
```console
33-
javascript-appsync-sam-vtl:~$ aws cloudformation create-stack --stack-name serverless-api-pipeline --template-body file://pipeline.yaml --capabilities CAPABILITY_IAM
38+
```bash
39+
git remote add origin <GitHub_Repository_URL>
40+
git push origin main
3441
```
35-
The pipeline will attempt to run and will fail at the SourceCodeRepo stage as there is no code in the AWS CodeCommit yet.
3642

37-
***NOTE:** If you change stack name, avoid stack names longer than 25 characters. In case you need longer stack names, check comments in the pipeline.yaml and update accordingly.*
38-
39-
***Note:** You may need to set up AWS CodeCommit repository access for HTTPS users [using Git credentials](https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-gc.html?icmpid=docs_acc_console_connect_np) and [set up the AWS CLI Credential Helper](https://docs.aws.amazon.com/console/codecommit/connect-tc-alert-np).*
40-
41-
Once you have access to the code repository, navigate to the javascript-appsync-sam-vtl folder, and if you changed stack name, make sure that Parameters section of template.yaml is updated with the output values from the shared Amazon Cognito stack, and push the code base to CodeCommit to start an automated deployment:
43+
To create the pipeline, run the following command:
4244

4345
```console
44-
javascript-appsync-sam-vtl:~$ git remote add origin <URL to AWS CodeCommit repository>
45-
javascript-appsync-sam-vtl:~$ git push origin main
46+
javascript-appsync-sam-vtl:~$ aws cloudformation create-stack --stack-name serverless-api-pipeline --template-body file://pipeline.yaml --capabilities CAPABILITY_IAM --parameter-overrides \
47+
gitHubOwner=<GITHUB_OWNER> \
48+
gitHubRepo=<GITHUB_REPOSITORY_NAME> \
49+
gitHubBranch=<GITHUB_BRANCH_NAME> \
50+
gitHubToken=<GITHUB_PERSONAL_ACCESS_TOKEN>
4651
```
4752

4853
Navigate to the AWS CodePipeline in the AWS Management Console and release this change if needed by clicking "Release change" button.

serverless-graphql-api/javascript-appsync-sam-vtl/pipeline.yaml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ AWSTemplateFormatVersion: 2010-09-09
55
Description: >
66
This template generates a 2-environment CI/CD Pipeline for sample serverless API application
77
Based on https://github.com/aws-samples/cookiecutter-aws-sam-pipeline
8+
Parameters:
9+
gitHubOwner:
10+
Type: String
11+
gitHubRepo:
12+
Type: String
13+
gitHubBranch:
14+
Type: String
15+
gitHubToken:
16+
Type: String
817

918
Resources:
1019
CodeRepository:
@@ -43,7 +52,7 @@ Resources:
4352
Environment:
4453
Type: LINUX_CONTAINER
4554
ComputeType: BUILD_GENERAL1_SMALL
46-
Image: aws/codebuild/amazonlinux2-x86_64-standard:4.0
55+
Image: aws/codebuild/amazonlinux2-x86_64-standard:5.0
4756
EnvironmentVariables:
4857
- Name: BUILD_OUTPUT_BUCKET
4958
Value: !Ref BuildArtifactsBucket
@@ -69,7 +78,7 @@ Resources:
6978
Environment:
7079
Type: LINUX_CONTAINER
7180
ComputeType: BUILD_GENERAL1_SMALL
72-
Image: aws/codebuild/amazonlinux2-x86_64-standard:4.0
81+
Image: aws/codebuild/amazonlinux2-x86_64-standard:5.0
7382
EnvironmentVariables:
7483
- Name: TEST_APPLICATION_STACK_NAME
7584
Value: !Sub ${AWS::StackName}-Testing
@@ -98,12 +107,14 @@ Resources:
98107
- Name: SourceCodeRepo
99108
ActionTypeId:
100109
Category: Source
101-
Owner: AWS
102-
Provider: CodeCommit
110+
Owner: ThirdParty
111+
Provider: GitHub
103112
Version: "1"
104113
Configuration:
105-
RepositoryName: !GetAtt CodeRepository.Name
106-
BranchName: main
114+
Owner: !Ref gitHubOwner
115+
Repo: !Ref gitHubRepo
116+
Branch: !Ref gitHubBranch
117+
OAuthToken: !Ref gitHubToken
107118
OutputArtifacts:
108119
- Name: SourceCodeAsZip
109120
RunOrder: 1

0 commit comments

Comments
 (0)