Skip to content

Instantly share code, notes, and snippets.

@wmakeev
Last active September 4, 2020 15:20
Show Gist options
  • Save wmakeev/4c7a890cf08b23389ef92e459cec721c to your computer and use it in GitHub Desktop.
Save wmakeev/4c7a890cf08b23389ef92e459cec721c to your computer and use it in GitHub Desktop.
[AWS CI] #aws #sam #codepipeline #ci #typescript #git

Setup CI on AWS CodeCommit

Based on Building a continuous delivery pipeline for a Lambda application with AWS CodePipeline.

Setup SSH

Test connection

ssh git-codecommit.eu-west-1.amazonaws.com

Create CodeCommit repository

Get repository ssh url

ssh://git-codecommit.eu-west-1.amazonaws.com/v1/repos/my-repo

Add remote to local git project

git remote add origin ssh://git-codecommit.eu-west-1.amazonaws.com/v1/repos/my-repo

git push

or

git remote add codecommit ssh://git-codecommit.eu-west-1.amazonaws.com/v1/repos/my-repo

git push codecommit master

Make S3 bucket for artifacts

aws s3 mb s3://my-repo-lambda-deployment-artifacts

Create an AWS CloudFormation role

Create an AWS CloudFormation role

Create a role that gives AWS CloudFormation permission to access AWS resources.

  1. Open the roles page in the IAM console.

  2. Choose Create role.

  3. Create a role with the following properties.

    • Trusted entity – AWS CloudFormation
    • Permissions – AWSLambdaExecute
    • Role name – cfn-lambda-pipeline
  4. Open the role. Under the Permissions tab, choose Add inline policy.

  5. In Create Policy, choose the JSON tab and add the following policy.

{
    "Statement": [
        {
            "Action": [
                "apigateway:*",
                "codedeploy:*",
                "lambda:*",
                "cloudformation:CreateChangeSet",
                "iam:GetRole",
                "iam:CreateRole",
                "iam:DeleteRole",
                "iam:PutRolePolicy",
                "iam:AttachRolePolicy",
                "iam:DeleteRolePolicy",
                "iam:DetachRolePolicy",
                "iam:PassRole",
                "s3:GetObject",
                "s3:GetObjectVersion",
                "s3:GetBucketVersioning"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ],
    "Version": "2012-10-17"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment