Skip to content

Conversation

juliareynolds-nava
Copy link
Collaborator

🎫 Ticket

https://jira.cms.gov/browse/PLT-1340

🛠 Changes

Removed terraform commands. Added opentofu commands.

ℹ️ Context

To standardize on Opentofu.

🧪 Validation

Validated by running the bcda-app Deploy-All workflow: https://github.com/CMSgov/bcda-app/actions/runs/17836121473/job/50713768183

Comment on lines 160 to 164
- name: Install terraform
- name: Install Opentofu
uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
with:
directory: ./terraform
uses: cmsgov/cdap/actions/setup-tfenv-terraform@main
- name: Init, Plan Terraform
- uses: cmsgov/cdap/actions/setup-tenv@8343fb96563ce4b74c4dececee9b268f42bd4a40
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section should look like this:

      - name: Install Cosign to verify OpenTofu install
        uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
      - name: Install OpenTofu
        uses: cmsgov/cdap/actions/setup-tenv@8343fb96563ce4b74c4dececee9b268f42bd4a40

- name: Get AMIs
run: |
export BCDA_AMI=`aws ec2 describe-images --region ${{ vars.AWS_REGION }} --filters 'Name=tag:app,Values=bcda-app' 'Name=tag:version,Values=${{ env.RELEASE_VERSION }}' --query 'Images[*][CreationDate,ImageId] | reverse(sort_by(@,&[0])) | [0][1]' --output text`
echo "BCDA_AMI=$BCDA_AMI" >> $GITHUB_ENV
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in the README I linked, the TENV_GITHUB_TOKEN must be available to all steps running tofu commands. Set it at the top level of the workflow.

export TF_CLI_ARGS="-no-color"
terraform init
terraform apply bcda-release-api-worker.tfplan
tofu init
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be dropped. No need to init again.

export APP_DB_PW=${STRS[2]}
cd terraform/${{ env.RELEASE_ENV }}
touch bcda-release-api-worker-vars.tfvars
export TF_CLI_ARGS="-no-color"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These -no-color args can be dropped here and in the next step. Unlike Jenkins, GHA can handle color output.

- name: Get AMIs
run: |
export BCDA_AMI=`aws ec2 describe-images --region ${{ vars.AWS_REGION }} --filters 'Name=tag:app,Values=bcda-app' 'Name=tag:version,Values=${{ env.RELEASE_VERSION }}' --query 'Images[*][CreationDate,ImageId] | reverse(sort_by(@,&[0])) | [0][1]' --output text`
echo "BCDA_AMI=$BCDA_AMI" >> $GITHUB_ENV
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in the README I linked, the TENV_GITHUB_TOKEN must be available to all steps running tofu commands. Set it at the top level of the workflow.

Comment on lines +162 to +164
- name: Install Cosign to verify OpenTofu install
uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
- name: Install OpenTofu
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies, I'm realizing these names are more correct:

Suggested change
- name: Install Cosign to verify OpenTofu install
uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
- name: Install OpenTofu
- name: Install Cosign to verify tenv and tofu installs
uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
- name: Install tenv

- name: Terraform Apply
- name: OpenTofu Apply
run: |
cd terraform/${{ env.RELEASE_ENV }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add working-directory to this step and drop the cd command.

contents: read

env:
TENV_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this down below TEST_ACO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants