Skip to content

Commit 38744ab

Browse files
authored
Merge pull request #22 from sonikro/create-security-group
Automatically creates security group if no SgID is provided
2 parents 44ac3d4 + 481457b commit 38744ab

File tree

10 files changed

+956
-71
lines changed

10 files changed

+956
-71
lines changed

Diff for: .github/workflows/test.yml

+24-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
npm install
1616
- run: |
1717
npm run all
18-
test:
18+
test-existing-sg:
1919
runs-on: ubuntu-latest
2020
if: github.repository_owner == 'sonikro'
2121
permissions:
@@ -39,3 +39,26 @@ jobs:
3939
terraform -v
4040
echo "Hello World. I am ${{github.repository}}"
4141
echo "Testing $GITHUB_REPOSITORY variable"
42+
test-new-sg:
43+
runs-on: ubuntu-latest
44+
if: github.repository_owner == 'sonikro'
45+
permissions:
46+
contents: read
47+
id-token: write
48+
steps:
49+
- uses: actions/checkout@v3
50+
51+
- uses: ./
52+
with:
53+
role_arn: "${{secrets.TEST_ROLE_ARN}}"
54+
image: hashicorp/terraform:latest
55+
region: us-east-1
56+
vpc_id: "${{secrets.TEST_VPC_ID}}"
57+
subnet_ids: |
58+
${{secrets.TEST_SUBNET_ID}}
59+
shell: sh
60+
run: |
61+
ls -la
62+
terraform -v
63+
echo "Hello World. I am ${{github.repository}}"
64+
echo "Testing $GITHUB_REPOSITORY variable"

Diff for: README.md

+38-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ The policy attattched to this role must have at least these permissions:
8989
"iam:PassRole",
9090
"logs:CreateLogGroup",
9191
"logs:GetLogEvents",
92-
"s3:*"
92+
"s3:*",
93+
"ec2:DescribeSecurityGroups",
94+
"ec2:DescribeSecurityGroupRules",
95+
"ec2:AuthorizeSecurityGroupEgress",
96+
"ec2:CreateSecurityGroup",
97+
"ec2:AuthorizeSecurityGroupIngress",
98+
"ec2:DeleteSecurityGroup"
9399
],
94100
"Resource": "*"
95101
},
@@ -111,6 +117,36 @@ The policy attattched to this role must have at least these permissions:
111117
```
112118
### Usage in your workflow
113119

120+
#### Easiest way to get started
121+
122+
123+
```yaml
124+
jobs:
125+
terraform:
126+
runs-on: ubuntu-latest
127+
permissions:
128+
contents: read
129+
id-token: write
130+
steps:
131+
- uses: actions/checkout@v3
132+
133+
- uses: sonikro/aws-run@v1
134+
with:
135+
role_arn: "${{secrets.ROLE_ARN}}"
136+
image: hashicorp/terraform:latest
137+
region: us-east-1
138+
vpc_id: "${{secrets.VPC_ID}}"
139+
subnet_ids: |
140+
${{secrets.SUBNBET_ID}}
141+
shell: sh
142+
run: |
143+
terraform apply
144+
```
145+
146+
#### Specifying a custom security group id
147+
148+
If you don't want the action to create a temporary security-group for the remote execution (the security group blocks all incoming traffic and allows all outgoing traffic), you must specify the **security_group_id** argument
149+
114150
```yaml
115151
jobs:
116152
terraform:
@@ -177,7 +213,7 @@ In the execution phase, the action will:
177213
- [X] Delete the Cloudwatch Logstream on Teardown
178214
- [X] Allow multiple Subnet IDs
179215
- [X] Stream the Cloudwatch logs as they happen, and not just at the end of the execution
180-
- [ ] Automatically create temporary security group if one is not provided
216+
- [X] Automatically create temporary security group if one is not provided
181217
- [ ] Automatically grab list of Subnets for VPC_ID, if Subnet_IDS are not provided
182218
- [ ] Mask secrets inside the Cloudwatch Logs
183219
- [X] Map all GitHub Contexts/ENVS into the ECS Container

Diff for: action.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ inputs:
3131
description: AWS Region to execute the operations
3232
default: us-east-1
3333
security_group_id:
34-
required: true
35-
description: Security Group to be used by the ECS Task
34+
required: false
35+
description: Security Group to be used by the ECS Task. If not informed, a temporary security group will be created with access to the internet
3636
run:
3737
required: true
3838
description: Script that will be executed in the remote environment

0 commit comments

Comments
 (0)