Skip to content

Commit 367c413

Browse files
authored
Merge pull request #56 from codeguru42/55-limit-github-role
55 limit GitHub role
2 parents 88e49d3 + 41f6c04 commit 367c413

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,9 @@ jobs:
1616
- name: Configure AWS credentials
1717
uses: aws-actions/configure-aws-credentials@v1-node16
1818
with:
19-
role-to-assume: arn:aws:iam::200049542062:role/gocapture/GithubRole
19+
role-to-assume: arn:aws:iam::200049542062:role/go_capture/GithubRole
2020
aws-region: us-west-1
2121

22-
- name: Deploy Github Role
23-
uses: aws-actions/aws-cloudformation-github-deploy@v1
24-
with:
25-
name: GoCaptureGithubRole
26-
template: cloud-formation/github-role.yaml
27-
parameter-overrides: "Repository=${{ github.repository }}"
28-
capabilities: CAPABILITY_NAMED_IAM
29-
no-fail-on-empty-changeset: 1
30-
3122
- name: Set ECR Stack Name
3223
id: ecr-stack-name
3324
run: echo ECR_STACK_NAME=GoCaptureECR >> $GITHUB_OUTPUT

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ pre-commit install
2121
```shell
2222
docker compose -f docker-compose-dev.yml -p go-capture-api up -d --build
2323
```
24+
25+
## Deploy GithubRole
26+
```shell
27+
aws cloudformation create-stack --stack-name GoCaptureGithubRole --parameters ParameterKey=Repository,ParameterValue=<github-repo> --template-body "$(cat cloud-formation/github-role.yaml)" --capabilities CAPABILITY_NAMED_IAM
28+
```

cloud-formation/github-role.yaml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Resources:
1616
Condition:
1717
StringLike:
1818
token.actions.githubusercontent.com:sub: !Sub repo:${Repository}:*
19-
Path: /gocapture/
19+
Path: /go_capture/
2020
Policies:
2121
- PolicyName: CloudFormationPolicy
2222
PolicyDocument: {
@@ -37,6 +37,21 @@ Resources:
3737
]
3838
}
3939
- PolicyName: IamPolicy
40+
PolicyDocument: {
41+
"Version": "2012-10-17",
42+
"Statement": [
43+
{
44+
"Effect": Allow,
45+
"Action": [
46+
iam:GetRole,
47+
iam:GetUser,
48+
iam:ListAccessKeys,
49+
],
50+
"Resource": "arn:aws:iam::200049542062:user/go_capture/*"
51+
},
52+
]
53+
}
54+
- PolicyName: IamDeployUserPolicy
4055
PolicyDocument: {
4156
"Version": "2012-10-17",
4257
"Statement": [
@@ -48,13 +63,13 @@ Resources:
4863
iam:DeleteUserPolicy,
4964
iam:GetRole,
5065
iam:GetUser,
51-
iam:ListAccessKeys,
5266
iam:PutRolePolicy,
5367
iam:PutRoleRole,
5468
iam:PutUserPolicy,
5569
iam:UpdateAssumeRolePolicy,
70+
iam:ListAccessKeys,
5671
],
57-
"Resource": "*"
72+
"Resource": "arn:aws:iam::200049542062:user/go_capture/beta_deploy"
5873
},
5974
]
6075
}

0 commit comments

Comments
 (0)