Skip to content

Commit 2d7e667

Browse files
authored
feat: Atmos Pro Support (cloudposse#72)
* support atmos pro * added tests * added tests * added tests * added tests * added tests * make readme
1 parent 5901553 commit 2d7e667

8 files changed

Lines changed: 132 additions & 4 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: "Test - Atmos Pro Enabled"
2+
3+
on:
4+
workflow_dispatch: {}
5+
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
9+
env:
10+
AWS_REGION: us-east-2
11+
12+
# Permissions required for assuming AWS identity
13+
permissions:
14+
id-token: write
15+
contents: read
16+
17+
jobs:
18+
setup:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Setup
22+
run: echo "Do setup"
23+
24+
test:
25+
runs-on: ubuntu-latest
26+
continue-on-error: true
27+
needs: [setup]
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
with:
32+
ref: ${{ github.event.pull_request.head.ref }}
33+
34+
- name: Setup Atmos Test Config
35+
shell: bash
36+
run: |
37+
mkdir -p ${{ runner.temp }}
38+
cp ./tests/opentofu/atmos.yaml ${{ runner.temp }}/atmos.yaml
39+
sed -i -e 's#__INFRACOST_ENABLED__#false#g' ${{ runner.temp }}/atmos.yaml
40+
sed -i -e 's#__STORAGE_REGION__#${{ env.AWS_REGION }}#g' ${{ runner.temp }}/atmos.yaml
41+
sed -i -e 's#__STORAGE_BUCKET__#${{ secrets.TERRAFORM_STATE_BUCKET }}#g' ${{ runner.temp }}/atmos.yaml
42+
sed -i -e 's#__STORAGE_TABLE__#${{ secrets.TERRAFORM_STATE_TABLE }}#g' ${{ runner.temp }}/atmos.yaml
43+
sed -i -e 's#__STORAGE_ROLE__#${{ secrets.TERRAFORM_STATE_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
44+
sed -i -e 's#__PLAN_ROLE__#${{ secrets.TERRAFORM_APPLY_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
45+
sed -i -e 's#__APPLY_ROLE__#${{ secrets.TERRAFORM_APPLY_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
46+
47+
cat ${{ runner.temp }}/atmos.yaml
48+
49+
- name: Plan Atmos Component
50+
uses: cloudposse/github-action-atmos-terraform-plan@v4
51+
with:
52+
component: "foobar-atmos-pro"
53+
stack: "plat-ue2-sandbox"
54+
atmos-config-path: ${{ runner.temp }}
55+
56+
- uses: actions/checkout@v4
57+
with:
58+
ref: ${{ github.event.pull_request.head.ref }}
59+
60+
- name: Wait 15 sec to wait s3 bucket would be consistent (read after write consistency)
61+
shell: bash
62+
run: |
63+
sleep 15;
64+
65+
- name: Apply Atmos Pro Component
66+
id: current
67+
uses: ./
68+
with:
69+
component: "foobar-atmos-pro"
70+
stack: "plat-ue2-sandbox"
71+
atmos-config-path: ${{ runner.temp }}
72+
atmos-version: ">= 1.174.0"
73+
74+
outputs:
75+
result: ${{ steps.current.outputs.status }}
76+
77+
assert:
78+
runs-on: ubuntu-latest
79+
needs: [test]
80+
steps:
81+
- uses: nick-fields/assert-action@v2
82+
with:
83+
expected: 'succeeded'
84+
actual: "${{ needs.test.outputs.result }}"
85+
86+
teardown:
87+
runs-on: ubuntu-latest
88+
needs: [assert]
89+
if: ${{ always() }}
90+
steps:
91+
- name: Tear down
92+
run: echo "Do Tear down"

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ Which would produce the same behavior as in `v0`, doing this:
395395

396396

397397

398+
399+
400+
401+
398402
<!-- markdownlint-disable -->
399403

400404
## Inputs

action.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ runs:
8888
- component: ${{ inputs.component }}
8989
stack: ${{ inputs.stack }}
9090
settingsPath: settings.github.actions_enabled
91-
outputPath: enabled
91+
outputPath: github-actions-enabled
92+
- component: ${{ inputs.component }}
93+
stack: ${{ inputs.stack }}
94+
settingsPath: settings.pro.enabled
95+
outputPath: atmos-pro-enabled
9296
- component: ${{ inputs.component }}
9397
stack: ${{ inputs.stack }}
9498
settingsPath: component_info.component_path
@@ -206,7 +210,7 @@ runs:
206210
- name: Check If GitHub Actions is Enabled For Component
207211
shell: bash
208212
run: |
209-
if [[ "${{ fromJson(steps.atmos-settings.outputs.settings).enabled }}" == "true" ]]; then
213+
if [[ "${{ fromJson(steps.atmos-settings.outputs.settings).github-actions-enabled }}" == "true" || "${{ fromJson(steps.atmos-settings.outputs.settings).atmos-pro-enabled }}" == "true" ]]; then
210214
echo "ACTIONS_ENABLED=true" >> $GITHUB_ENV
211215
else
212216
echo "ACTIONS_ENABLED=false" >> $GITHUB_ENV
@@ -374,7 +378,7 @@ runs:
374378
- name: Cache .terraform
375379
id: cache
376380
uses: actions/cache@v4
377-
if: ${{ fromJson(steps.atmos-settings.outputs.settings).enabled }}
381+
if: env.ACTIONS_ENABLED == 'true'
378382
with:
379383
path: |
380384
${{ steps.vars.outputs.component_path }}/.terraform

docs/github-action.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| Name | Description | Default | Required |
66
|------|-------------|---------|----------|
77
| atmos-config-path | The path to the atmos.yaml file | N/A | true |
8-
| atmos-version | The version of atmos to install | >= 1.99.0 | false |
8+
| atmos-version | The version of atmos to install | >= 1.158.0 | false |
99
| branding-logo-image | Branding logo image url | https://cloudposse.com/logo-300x69.svg | false |
1010
| branding-logo-url | Branding logo url | https://cloudposse.com/ | false |
1111
| component | The name of the component to apply. | N/A | true |
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
components:
2+
terraform:
3+
foobar-atmos-pro:
4+
metadata:
5+
component: foobar
6+
settings:
7+
pro:
8+
enabled: true
9+
github:
10+
actions_enabled: false
11+
vars:
12+
example: blue
13+
enabled: true

tests/opentofu/stacks/orgs/foo/plat/sandbox/plat-ue2-sandbox.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import:
22
- catalog/foobar
3+
- catalog/foobar-atmos-pro
34

45
terraform:
56
backend_type: s3
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
components:
2+
terraform:
3+
foobar-atmos-pro:
4+
metadata:
5+
component: foobar
6+
settings:
7+
pro:
8+
enabled: true
9+
github:
10+
actions_enabled: false
11+
vars:
12+
example: blue
13+
enabled: true

tests/terraform/stacks/orgs/foo/plat/sandbox/plat-ue2-sandbox.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import:
22
- catalog/foobar
3+
- catalog/foobar-atmos-pro
34

45
terraform:
56
backend_type: s3

0 commit comments

Comments
 (0)