Skip to content

Commit 9e7c58c

Browse files
authored
fix: Scope plan storage AWS credentials to prevent Atmos auth interference (#93)
1 parent 77f73c2 commit 9e7c58c

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

action.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,11 @@ runs:
268268
echo "renewed_plan_file=$RENEWED_PLAN_FILE" >> $GITHUB_OUTPUT
269269
echo "lock_file=$LOCK_FILE" >> $GITHUB_OUTPUT
270270
271+
# Configure Plan Storage AWS Credentials with output-only mode to avoid polluting
272+
# the environment. Credentials are passed explicitly to subsequent steps that need them.
273+
# This prevents plan storage credentials from interfering with Atmos auth.
271274
- name: Configure Plan Storage AWS Credentials
275+
id: plan-storage-credentials
272276
uses: aws-actions/configure-aws-credentials@v4
273277
if: ${{ ( fromJson(steps.atmos-settings.outputs.settings).plan-repository-type == 's3' ||
274278
fromJson(steps.atmos-settings.outputs.settings).plan-repository-type == '' ||
@@ -284,11 +288,18 @@ runs:
284288
role-to-assume: ${{ fromJson(steps.atmos-settings.outputs.settings).terraform-state-role }}
285289
role-session-name: "atmos-terraform-state-gitops"
286290
mask-aws-account-id: "no"
291+
output-credentials: true
292+
output-env-credentials: false
287293

288294
- name: Retrieve Plan
289295
if: ${{ env.ACTIONS_ENABLED == 'true' && inputs.plan-storage == 'true'}}
290296
uses: cloudposse/github-action-terraform-plan-storage@v1
291297
continue-on-error: true
298+
env:
299+
AWS_ACCESS_KEY_ID: ${{ steps.plan-storage-credentials.outputs.aws-access-key-id }}
300+
AWS_SECRET_ACCESS_KEY: ${{ steps.plan-storage-credentials.outputs.aws-secret-access-key }}
301+
AWS_SESSION_TOKEN: ${{ steps.plan-storage-credentials.outputs.aws-session-token }}
302+
AWS_REGION: ${{ fromJson(steps.atmos-settings.outputs.settings).aws-region }}
292303
with:
293304
action: getPlan
294305
commitSHA: ${{ inputs.sha }}
@@ -309,6 +320,11 @@ runs:
309320
if: ${{ env.ACTIONS_ENABLED == 'true' && inputs.plan-storage == 'true'}}
310321
uses: cloudposse/github-action-terraform-plan-storage@v1
311322
continue-on-error: true
323+
env:
324+
AWS_ACCESS_KEY_ID: ${{ steps.plan-storage-credentials.outputs.aws-access-key-id }}
325+
AWS_SECRET_ACCESS_KEY: ${{ steps.plan-storage-credentials.outputs.aws-secret-access-key }}
326+
AWS_SESSION_TOKEN: ${{ steps.plan-storage-credentials.outputs.aws-session-token }}
327+
AWS_REGION: ${{ fromJson(steps.atmos-settings.outputs.settings).aws-region }}
312328
with:
313329
action: getPlan
314330
commitSHA: ${{ inputs.sha }}
@@ -325,7 +341,7 @@ runs:
325341
tableName: ${{ fromJson(steps.atmos-settings.outputs.settings).terraform-state-table }}
326342
bucketName: ${{ fromJson(steps.atmos-settings.outputs.settings).terraform-state-bucket }}
327343

328-
- name: Configure Plan AWS Credentials
344+
- name: Configure Apply AWS Credentials
329345
uses: aws-actions/configure-aws-credentials@v4
330346
if: ${{ fromJson(steps.atmos-settings.outputs.settings).aws-region != '' &&
331347
fromJson(steps.atmos-settings.outputs.settings).aws-region != 'null' &&

0 commit comments

Comments
 (0)