-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from fuller-inc/introduce-cicd
introduce CI/CD
- Loading branch information
Showing
4 changed files
with
209 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: deploy to production | ||
on: | ||
push: | ||
# branches: | ||
# - main | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
statuses: write | ||
contents: read | ||
environment: production | ||
|
||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: "1.18" | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: restore cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }} | ||
- name: download dependencies | ||
run: go mod download | ||
working-directory: provider/assume-role | ||
|
||
- name: build | ||
run: | | ||
make build | ||
working-directory: provider | ||
|
||
- uses: fuller-inc/actions-aws-assume-role@v1 | ||
with: | ||
aws-region: us-east-1 | ||
role-to-assume: arn:aws:iam::053160724612:role/aws-assume-role-github-actions-us-east-1 | ||
role-session-tagging: true | ||
use-node-id: true | ||
|
||
- name: deploy | ||
run: | | ||
make deploy | ||
working-directory: provider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
AWSTemplateFormatVersion: "2010-09-09" | ||
Description: > | ||
Continuous Deployment settings for aws-assume-role | ||
Resources: | ||
# Permission Boundary for Roles | ||
PermissionsBoundary: | ||
Type: AWS::IAM::ManagedPolicy | ||
Properties: | ||
Description: Permission Boundary for aws-assume-role Roles | ||
ManagedPolicyName: !Sub "aws-assume-role-permissions-boundary-${AWS::Region}" | ||
PolicyDocument: | ||
Version: "2012-10-17" | ||
Statement: | ||
- Sid: ServiceBoundaries | ||
Effect: Allow | ||
Action: | ||
- "logs:*" | ||
- "sts:*" | ||
Resource: "*" | ||
|
||
# CloudFormation Service Role for deploying SAM templates | ||
DeploymentRole: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
RoleName: !Sub "aws-assume-role-cfn-service-role-${AWS::Region}" | ||
AssumeRolePolicyDocument: | ||
Version: "2012-10-17" | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
Service: | ||
- cloudformation.amazonaws.com | ||
Action: | ||
- "sts:AssumeRole" | ||
Policies: | ||
- PolicyName: deploy-sam-templates | ||
PolicyDocument: | ||
Version: "2012-10-17" | ||
Statement: | ||
- Sid: CreateOrChangeOnlyWithBoundary | ||
Effect: Allow | ||
Action: | ||
- "iam:CreateRole" | ||
- "iam:PutRolePolicy" | ||
- "iam:AttachRolePolicy" | ||
- "iam:DetachRolePolicy" | ||
- "iam:DeleteRolePolicy" | ||
- "iam:PutRolePermissionsBoundary" | ||
Resource: "*" | ||
Condition: | ||
StringEquals: | ||
"iam:PermissionsBoundary": !Ref PermissionsBoundary | ||
- Sid: NoBoundaryPolicyEdit | ||
Effect: Deny | ||
Action: | ||
- "iam:CreatePolicyVersion" | ||
- "iam:DeletePolicy" | ||
- "iam:DeletePolicyVersion" | ||
- "iam:SetDefaultPolicyVersion" | ||
Resource: | ||
- !Ref PermissionsBoundary | ||
- Sid: NoBoundaryRoleDelete | ||
Effect: Deny | ||
Action: | ||
- "iam:DeleteRolePermissionsBoundary" | ||
Resource: "*" | ||
- Sid: OtherIAMTasks | ||
Effect: Allow | ||
Resource: "*" | ||
Action: | ||
# handle IAM Roles | ||
- "iam:ListRolePolicies" | ||
- "iam:ListRoleTags" | ||
- "iam:ListRoles" | ||
- "iam:GetRole" | ||
- "iam:GetRolePolicy" | ||
- "iam:ListAttachedRolePolicies" | ||
- "iam:UpdateRole" | ||
- "iam:UpdateRoleDescription" | ||
- "iam:UpdateAssumeRolePolicy" | ||
- "iam:TagRole" | ||
- "iam:UntagRole" | ||
- "iam:DeleteRole" | ||
- "iam:PassRole" | ||
|
||
# handle Service Linked Roles | ||
- "iam:ListPoliciesGrantingServiceAccess" | ||
- "iam:CreateServiceLinkedRole" | ||
- "iam:DeleteServiceLinkedRole" | ||
- "iam:GetServiceLinkedRoleDeletionStatus" | ||
|
||
- Sid: CloudFormationStackOperation | ||
Effect: Allow | ||
Action: | ||
- "cloudformation:*" | ||
- "lambda:*" | ||
- "apigateway:*" | ||
- "s3:*" | ||
Resource: | ||
- "*" | ||
|
||
# for GitHub Actions | ||
GitHubActionsRole: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
RoleName: !Sub "aws-assume-role-github-actions-${AWS::Region}" | ||
AssumeRolePolicyDocument: | ||
Version: "2012-10-17" | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
AWS: arn:aws:iam::053160724612:root | ||
Action: "sts:AssumeRole" | ||
Condition: | ||
StringEquals: | ||
"sts:ExternalId": "R_kgDOFMsDjw" | ||
"aws:RequestTag/Environment": "production" | ||
- Effect: Allow | ||
Principal: | ||
AWS: arn:aws:iam::053160724612:root | ||
Action: "sts:TagSession" | ||
Policies: | ||
- PolicyName: SAMDeployment | ||
PolicyDocument: | ||
Version: "2012-10-17" | ||
Statement: | ||
- Sid: PassRoleToCloudFormation | ||
Effect: Allow | ||
Action: "iam:PassRole" | ||
Resource: !GetAtt DeploymentRole.Arn | ||
- Sid: CloudFormationStackOperation | ||
Effect: Allow | ||
Action: "cloudformation:*" | ||
Resource: | ||
- !Sub "arn:aws:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/aws-assume-role/*" | ||
- Sid: CloudFormationDenyImport | ||
Effect: Deny | ||
Action: "cloudformation:*" | ||
Resource: "*" | ||
Condition: | ||
"ForAnyValue:StringLike": | ||
"cloudformation:ImportResourceTypes": ["*"] | ||
- Sid: S3Operation | ||
Effect: Allow | ||
Action: "s3:*" | ||
Resource: "arn:aws:s3:::aws-sam-cli-managed-default-samclisourcebucket-*/*" | ||
- Sid: S3ListOperation | ||
Effect: Allow | ||
Action: "s3:ListBucket" | ||
Resource: "arn:aws:s3:::aws-sam-cli-managed-default-samclisourcebucket-*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters