Skip to content

Commit b498569

Browse files
committed
logs in ecr 2
1 parent 3de59ce commit b498569

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

.github/workflows/deploy-to-ecr.yml

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ jobs:
2727
role-to-assume: ${{ env.AWS_IAM_ROLE_ARN }}
2828
aws-region: ${{ env.AWS_REGION }}
2929

30+
- name: Debug AWS Environment Variables Set by configure-aws-credentials
31+
run: |
32+
echo "Value of AWS_REGION env var: '${AWS_REGION}'"
33+
echo "Value of AWS_DEFAULT_REGION env var: '${AWS_DEFAULT_REGION}'"
34+
echo "--- All AWS related env vars ---"
35+
printenv | grep AWS_
36+
echo "--------------------------------"
37+
3038
- name: Setup Terraform
3139
uses: hashicorp/setup-terraform@v3
3240
with:
@@ -49,44 +57,41 @@ jobs:
4957
# run: echo "ECR_REPOSITORY_URL=$(terraform output -raw ecr_repository_url)" >> $GITHUB_ENV
5058
# working-directory: ./terraform
5159

52-
- name: Get ECR Repository URL and Add Debug Logs
53-
id: get_ecr_url
54-
working-directory: ./terraform # Asegúrate de que esta es la ruta correcta a tu directorio de Terraform
60+
- name: Get Terraform Outputs (ECR URL and AWS Region)
61+
id: get_tf_outputs
62+
working-directory: ./terraform
5563
run: |
56-
echo "INFO: Current directory is $(pwd)"
57-
echo "INFO: Listing Terraform files in working directory:"
58-
ls -la
59-
6064
echo "INFO: Attempting to get ECR repository URL from Terraform output..."
61-
# Captura la salida en una variable para poder inspeccionarla y usarla
6265
TF_OUTPUT_ECR_URL=$(terraform output -raw ecr_repository_url)
63-
64-
echo "DEBUG: Raw output from 'terraform output -raw ecr_repository_url' is:"
66+
echo "DEBUG: Raw output for 'ecr_repository_url' (value in variable, may be masked by GHA logger when printed):"
6567
echo "--------------------------------------------------"
6668
echo "${TF_OUTPUT_ECR_URL}"
6769
echo "--------------------------------------------------"
6870
69-
# Verifica si la salida está vacía
70-
if [ -z "${TF_OUTPUT_ECR_URL}" ]; then
71-
echo "::error title=Terraform Output Empty::Terraform output for 'ecr_repository_url' was empty. Please check your Terraform configuration and ensure the output value 'ecr_repository_url' is correctly defined and populated after 'terraform apply'."
72-
# Opcionalmente, puedes hacer que el job falle si esto es crítico
73-
# exit 1
74-
fi
75-
76-
# Verifica si la salida contiene "***" lo cual indicaste como un problema
7771
if [[ "${TF_OUTPUT_ECR_URL}" == *"***"* ]]; then
78-
echo "::warning title=Problematic ECR URL::The ECR Repository URL from Terraform output contains '***'. This usually indicates an issue with region resolution or configuration within your Terraform code."
79-
echo "Problematic URL: ${TF_OUTPUT_ECR_URL}"
72+
echo "::warning title=Problematic ECR URL::The ECR Repository URL from Terraform output appears to contain literal '***'. This is unexpected if GHA logger masking is the cause."
8073
else
81-
echo "INFO: The ECR Repository URL obtained seems structurally valid (does not contain '***')."
74+
echo "INFO: The ECR Repository URL (internal value) does not seem to contain literal '***'."
8275
fi
8376
8477
echo "INFO: Setting GITHUB_ENV variable ECR_REPOSITORY_URL..."
8578
echo "ECR_REPOSITORY_URL=${TF_OUTPUT_ECR_URL}" >> $GITHUB_ENV
86-
echo "INFO: ECR_REPOSITORY_URL has been set in GITHUB_ENV."
79+
echo "INFO: ECR_REPOSITORY_URL has been set."
80+
81+
echo "INFO: Attempting to get configured AWS region from Terraform output..."
82+
TF_OUTPUT_AWS_REGION=$(terraform output -raw aws_region_configured)
83+
echo "DEBUG: Raw output for 'aws_region_configured' (this is var.AWS_REGION in Terraform):"
84+
echo "--------------------------------------------------"
85+
echo "Value: '${TF_OUTPUT_AWS_REGION}'" # Encapsulado en comillas para ver espacios
86+
echo "--------------------------------------------------"
8787
88-
# Para verificar que se estableció correctamente en GITHUB_ENV (opcional, ya que el siguiente paso lo usará)
89-
# echo "Checking env.ECR_REPOSITORY_URL (simulated for next step): $ECR_REPOSITORY_URL"
88+
if [ -z "${TF_OUTPUT_AWS_REGION}" ]; then
89+
echo "::error title=Terraform AWS Region Empty::Terraform output for 'aws_region_configured' was empty."
90+
elif [[ "${TF_OUTPUT_AWS_REGION}" == *"***"* ]]; then
91+
echo "::warning title=Problematic AWS Region Output::Terraform output for 'aws_region_configured' contains '***'. This is unexpected."
92+
else
93+
echo "INFO: AWS Region configured in Terraform is: '${TF_OUTPUT_AWS_REGION}'"
94+
fi
9095
9196
- name: Login to Amazon ECR
9297
id: login-ecr

0 commit comments

Comments
 (0)