Skip to content

Commit

Permalink
support derived components
Browse files Browse the repository at this point in the history
  • Loading branch information
milldr committed Jul 10, 2023
1 parent ab2c5ff commit 1044fa2
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .github/workflows/test-derived.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Test Derived Component Settings
on:
# # Uncomment when test added first time to register workflow and comment it back after workflow would be registered
# #
# # Added pull_request to register workflow from the PR.
# # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo
# pull_request: {}
workflow_dispatch: {}

jobs:
test:
runs-on: ubuntu-latest
continue-on-error: true
outputs:
result: "${{ steps.current.outputs.value }}"
steps:
- name: Setup terraform
uses: hashicorp/setup-terraform@v2
- name: Setup atmos
uses: cloudposse/[email protected]
with:
install-wrapper: false
- name: Checkout
uses: actions/checkout@v3

- uses: ./
id: current
with:
component: derived-foo
stack: core-ue1-dev
settings-path: level1.level2.level3.secrets-arn

assert:
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: nick-fields/assert-action@v1
with:
expected: arn:aws:secretsmanager:us-east-1:000000000000:secret:MySecret-PlMes4
actual: "${{ needs.test.outputs.result }}"
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ runs:
- id: settings
shell: bash
run: |
value=$(atmos describe stacks -s ${{ inputs.stack }} --components ${{ inputs.component }} --sections=settings --format json | jq -rc --arg key "${{inputs.settings-path}}" '.. | select(.settings)?| .settings | select(has($key | split(".")[])) | getpath($key | split("."))')
value=$(atmos describe stacks -s ${{ inputs.stack }} --components ${{ inputs.component }} --sections=settings --format json | jq -rc --arg key "${{inputs.settings-path}}" '.. | select(.settings)?| .settings | select(has($key | split(".")[])) | getpath($key | split("."))' | jq -s .[-1])
echo "value=$value" >> $GITHUB_OUTPUT
10 changes: 10 additions & 0 deletions stacks/orgs/demo/dev/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,13 @@ components:
environment: ue1
stage: dev
foo: bar

derived-foo:
metadata:
inherits:
- foo
settings:
level1:
level2:
level3:
secrets-arn: arn:aws:secretsmanager:us-east-1:000000000000:secret:MySecret-PlMes4

0 comments on commit 1044fa2

Please sign in to comment.