Skip to content

Commit

Permalink
Merge pull request #22 from sonikro/create-security-group
Browse files Browse the repository at this point in the history
Automatically creates security group if no SgID is provided
  • Loading branch information
sonikro authored Jul 26, 2023
2 parents 44ac3d4 + 481457b commit 38744ab
Show file tree
Hide file tree
Showing 10 changed files with 956 additions and 71 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
npm install
- run: |
npm run all
test:
test-existing-sg:
runs-on: ubuntu-latest
if: github.repository_owner == 'sonikro'
permissions:
Expand All @@ -39,3 +39,26 @@ jobs:
terraform -v
echo "Hello World. I am ${{github.repository}}"
echo "Testing $GITHUB_REPOSITORY variable"
test-new-sg:
runs-on: ubuntu-latest
if: github.repository_owner == 'sonikro'
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3

- uses: ./
with:
role_arn: "${{secrets.TEST_ROLE_ARN}}"
image: hashicorp/terraform:latest
region: us-east-1
vpc_id: "${{secrets.TEST_VPC_ID}}"
subnet_ids: |
${{secrets.TEST_SUBNET_ID}}
shell: sh
run: |
ls -la
terraform -v
echo "Hello World. I am ${{github.repository}}"
echo "Testing $GITHUB_REPOSITORY variable"
40 changes: 38 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ The policy attattched to this role must have at least these permissions:
"iam:PassRole",
"logs:CreateLogGroup",
"logs:GetLogEvents",
"s3:*"
"s3:*",
"ec2:DescribeSecurityGroups",
"ec2:DescribeSecurityGroupRules",
"ec2:AuthorizeSecurityGroupEgress",
"ec2:CreateSecurityGroup",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:DeleteSecurityGroup"
],
"Resource": "*"
},
Expand All @@ -111,6 +117,36 @@ The policy attattched to this role must have at least these permissions:
```
### Usage in your workflow

#### Easiest way to get started


```yaml
jobs:
terraform:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3

- uses: sonikro/aws-run@v1
with:
role_arn: "${{secrets.ROLE_ARN}}"
image: hashicorp/terraform:latest
region: us-east-1
vpc_id: "${{secrets.VPC_ID}}"
subnet_ids: |
${{secrets.SUBNBET_ID}}
shell: sh
run: |
terraform apply
```
#### Specifying a custom security group id
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
```yaml
jobs:
terraform:
Expand Down Expand Up @@ -177,7 +213,7 @@ In the execution phase, the action will:
- [X] Delete the Cloudwatch Logstream on Teardown
- [X] Allow multiple Subnet IDs
- [X] Stream the Cloudwatch logs as they happen, and not just at the end of the execution
- [ ] Automatically create temporary security group if one is not provided
- [X] Automatically create temporary security group if one is not provided
- [ ] Automatically grab list of Subnets for VPC_ID, if Subnet_IDS are not provided
- [ ] Mask secrets inside the Cloudwatch Logs
- [X] Map all GitHub Contexts/ENVS into the ECS Container
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ inputs:
description: AWS Region to execute the operations
default: us-east-1
security_group_id:
required: true
description: Security Group to be used by the ECS Task
required: false
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
run:
required: true
description: Script that will be executed in the remote environment
Expand Down
Loading

0 comments on commit 38744ab

Please sign in to comment.