Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renew Lets Encrypt Certificates GitHub Action is broken #3978

Closed
jonnyry opened this issue Jun 17, 2024 · 1 comment · Fixed by #3979
Closed

Renew Lets Encrypt Certificates GitHub Action is broken #3978

jonnyry opened this issue Jun 17, 2024 · 1 comment · Fixed by #3979
Labels
bug Something isn't working

Comments

@jonnyry
Copy link
Contributor

jonnyry commented Jun 17, 2024

The Renew Lets Encrypt Certificates GitHub Action is broken...

1. Fails with AZURE_ENVIRONMENT: unbound variable

image

Fixing this by adding the following line to env vars on line 38 of the lets_encrypt.yml:

AZURE_ENVIRONMENT= ${{ vars.AZURE_ENVIRONMENT }}

Fixing the above then produces the next issue...

2. Fails on Azure login with tenant not found error

image

Looking more closely at the yaml, it looks like SUBCRIPTION_ID and TENANT_ID have their values mixed up:

ARM_SUBSCRIPTION_ID: ${{ fromJSON(secrets.AZURE_CREDENTIALS).tenantId }}
ARM_TENANT_ID: ${{ fromJSON(secrets.AZURE_CREDENTIALS).subscriptionId }}

Fixing the above then produces the next issue...

3. Fails to initialise terraform backend

image

The error above is produced by the following lines:

terraform init -input=false -backend=true -reconfigure \
-backend-config="resource_group_name=$TF_VAR_mgmt_resource_group_name" \
-backend-config="storage_account_name=$TF_VAR_mgmt_storage_account_name" \
-backend-config="container_name=$TF_VAR_terraform_state_container_name" \
-backend-config="key=${TRE_ID}"
# Convert the output to json
terraform output -json > ../tre_output.json

Appears that the env vars and not making into the terraform initialize command...

TF_VAR_mgmt_resource_group_name
TF_VAR_mgmt_storage_account_name
TF_VAR_terraform_state_container_name

Changing the following lines in letsencrypt.yaml from:

TERRAFORM_STATE_CONTAINER_NAME:
${{ secrets.TERRAFORM_STATE_CONTAINER_NAME && secrets.TERRAFORM_STATE_CONTAINER_NAME || 'tfstate' }}
MGMT_RESOURCE_GROUP_NAME: ${{ secrets.MGMT_RESOURCE_GROUP_NAME }}
MGMT_STORAGE_ACCOUNT_NAME: ${{ secrets.MGMT_STORAGE_ACCOUNT_NAME }}

to:

          TF_VAR_terraform_state_container_name: ${{ secrets.TERRAFORM_STATE_CONTAINER_NAME || 'tfstate' }}
          TF_VAR_mgmt_resource_group_name: ${{ secrets.MGMT_RESOURCE_GROUP_NAME }}
          TF_VAR_mgmt_storage_account_name: ${{ secrets.MGMT_STORAGE_ACCOUNT_NAME }}

fixes issue 3, and allows a certificate to be generated.

@jonnyry jonnyry added the bug Something isn't working label Jun 17, 2024
@jonnyry
Copy link
Contributor Author

jonnyry commented Jun 17, 2024

In summary the following fixes are required to lets_encrypt.yaml:

Make the following changes under the env section of the Renew Certificates job step:

1. Add the following line

AZURE_ENVIRONMENT= ${{ vars.AZURE_ENVIRONMENT }}

2. Change the following lines from:

ARM_SUBSCRIPTION_ID: ${{ fromJSON(secrets.AZURE_CREDENTIALS).tenantId }} 
ARM_TENANT_ID: ${{ fromJSON(secrets.AZURE_CREDENTIALS).subscriptionId }} 

To:

ARM_SUBSCRIPTION_ID: ${{ fromJSON(secrets.AZURE_CREDENTIALS).subscriptionId }} 
ARM_TENANT_ID: ${{ fromJSON(secrets.AZURE_CREDENTIALS).tenantId }} 

3. Change the following lines from:

TERRAFORM_STATE_CONTAINER_NAME: ${{ secrets.TERRAFORM_STATE_CONTAINER_NAME && secrets.TERRAFORM_STATE_CONTAINER_NAME || 'tfstate' }}
MGMT_RESOURCE_GROUP_NAME: ${{ secrets.MGMT_RESOURCE_GROUP_NAME }}
MGMT_STORAGE_ACCOUNT_NAME: ${{ secrets.MGMT_STORAGE_ACCOUNT_NAME }}

To:

TF_VAR_terraform_state_container_name: ${{ secrets.TERRAFORM_STATE_CONTAINER_NAME || 'tfstate' }}
TF_VAR_mgmt_resource_group_name: ${{ secrets.MGMT_RESOURCE_GROUP_NAME }}
TF_VAR_mgmt_storage_account_name: ${{ secrets.MGMT_STORAGE_ACCOUNT_NAME }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant