Skip to content

Commit

Permalink
Passing account number as json
Browse files Browse the repository at this point in the history
  • Loading branch information
sshrihar committed Apr 26, 2024
1 parent 86b3f6f commit a18e1ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/ecs_deploy_docker_taskdef.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
on:
workflow_call:
inputs:
account_number:
required: true
type: string
app_name:
required: true
type: string
Expand Down Expand Up @@ -33,9 +36,6 @@ on:
required: false
default: "staging"
type: string
secrets:
account_number:
required: true

jobs:
deploy_workflow:
Expand Down Expand Up @@ -86,15 +86,14 @@ jobs:
pipenv install && \
pipenv run python ${{ env.taskdef_file_script }} \
-pf code/${{ inputs.taskdef_file_vars }} -tt ${{ env.taskdef_file_template }} \
-acc ${{ secrets.account_number }} \
-acc ${{ fromJSON(inputs.account_number) }} \
-app ${{ inputs.app_name }}
echo "account_number_read=$(cat $script_dir/account_number.txt)" >> $GITHUB_ENV
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ inputs.aws_region }}
role-to-assume: arn:aws:iam::${{ env.account_number_read }}:role/${{ inputs.app_name }}-GithubActionsRole
role-to-assume: arn:aws:iam::${{ fromJSON(inputs.account_number) }}:role/${{ inputs.app_name }}-GithubActionsRole
role-session-name: GithubActionsSession

- name: Login to Amazon ECR
Expand Down
8 changes: 1 addition & 7 deletions Support/taskdef_template/taskdef_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,7 @@ def substitute_values(self):
self._substitute_secret_vars(user_data.get("secret_vars", []))
[user_data.pop(key) for key in ["env_vars", "secret_vars"] if key in user_data]
for sub in expected_sub:
self._subtitute_data(user_data, sub)

# Write account number to a file
script_dir = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(script_dir, "account_number.txt")
with open(file_path, "w") as file_obj:
file_obj.write(user_data["account_number"])
self._subtitute_data(user_data, sub)
return user_data["account_number"]


Expand Down

0 comments on commit a18e1ed

Please sign in to comment.