Skip to content

Commit e08101f

Browse files
committed
fix: Scope plan storage AWS credentials to prevent Atmos auth interference
1 parent 77f73c2 commit e08101f

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

action.yml

Lines changed: 16 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,17 @@ 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
287292

288293
- name: Retrieve Plan
289294
if: ${{ env.ACTIONS_ENABLED == 'true' && inputs.plan-storage == 'true'}}
290295
uses: cloudposse/github-action-terraform-plan-storage@v1
291296
continue-on-error: true
297+
env:
298+
AWS_ACCESS_KEY_ID: ${{ steps.plan-storage-credentials.outputs.aws-access-key-id }}
299+
AWS_SECRET_ACCESS_KEY: ${{ steps.plan-storage-credentials.outputs.aws-secret-access-key }}
300+
AWS_SESSION_TOKEN: ${{ steps.plan-storage-credentials.outputs.aws-session-token }}
301+
AWS_REGION: ${{ fromJson(steps.atmos-settings.outputs.settings).aws-region }}
292302
with:
293303
action: getPlan
294304
commitSHA: ${{ inputs.sha }}
@@ -309,6 +319,11 @@ runs:
309319
if: ${{ env.ACTIONS_ENABLED == 'true' && inputs.plan-storage == 'true'}}
310320
uses: cloudposse/github-action-terraform-plan-storage@v1
311321
continue-on-error: true
322+
env:
323+
AWS_ACCESS_KEY_ID: ${{ steps.plan-storage-credentials.outputs.aws-access-key-id }}
324+
AWS_SECRET_ACCESS_KEY: ${{ steps.plan-storage-credentials.outputs.aws-secret-access-key }}
325+
AWS_SESSION_TOKEN: ${{ steps.plan-storage-credentials.outputs.aws-session-token }}
326+
AWS_REGION: ${{ fromJson(steps.atmos-settings.outputs.settings).aws-region }}
312327
with:
313328
action: getPlan
314329
commitSHA: ${{ inputs.sha }}
@@ -325,7 +340,7 @@ runs:
325340
tableName: ${{ fromJson(steps.atmos-settings.outputs.settings).terraform-state-table }}
326341
bucketName: ${{ fromJson(steps.atmos-settings.outputs.settings).terraform-state-bucket }}
327342

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

0 commit comments

Comments
 (0)