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

region parameter not correctly override ${AWS_DEFAULT_REGION} env #220

Closed
DeliciousKokas opened this issue Sep 25, 2024 · 7 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@DeliciousKokas
Copy link

DeliciousKokas commented Sep 25, 2024

Orb version:

5.x

What happened:

During the running deploy_service_update job, it's generate error Invalid endpoint: https://ecs..amazonaws.com
It's seems to error related missing region parameter, but it's correctly setup already.

However, it's resolved when setting ${AWS_DEFAULT_REGION} which should be an optional.
Seems to during the steps, it directly refer to ${AWS_DEFAULT_REGION} env not parameter.

Expected behavior:

Make it region parameter override ${AWS_DEFAULT_REGION} env, and correct command refer to parameter.

Additional Information:

Taking look deploy_service_update job on orb source 5.x, below steps were included.
And it's not using registered parameter but only take it directly from ${AWS_DEFAULT_REGION}.

### 5.x
- when:
    condition: << parameters.skip_task_definition_registration >>
    steps:
        - run:
            command: |
                TASK_DEFINITION_ARN=$(aws ecs describe-task-definition \
                  --task-definition << parameters.family >> \
                  --output text \
                  --query 'taskDefinition.taskDefinitionArn' \
                  --profile << parameters.profile_name >> \
                  --region ${AWS_DEFAULT_REGION})
                echo "export CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN='${TASK_DEFINITION_ARN}'" >> $BASH_ENV
            name: Retrieve previous task definition

Same steps on version 4.1, there was no region flag. So I assuming it's only effected on 5.x.

### 4.1
- when:
    condition: << parameters.skip_task_definition_registration >>
    steps:
        - run:
            command: |
                TASK_DEFINITION_ARN=$(aws ecs describe-task-definition \
                  --task-definition << parameters.family >> \
                  --output text \
                  --query 'taskDefinition.taskDefinitionArn' \
                  --profile=<< parameters.profile_name >>)
                echo "export CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN='${TASK_DEFINITION_ARN}'" >> $BASH_ENV
            name: Retrieve previous task definition
@DeliciousKokas DeliciousKokas added the bug Something isn't working label Sep 25, 2024
@marboledacci
Copy link
Contributor

I think this was partially fixed with #219. I'm creating #221 so this fix is applied to the job as well.

@marboledacci
Copy link
Contributor

I think this new version should solve your problem 5.2.1

@marboledacci marboledacci self-assigned this Sep 25, 2024
@DeliciousKokas
Copy link
Author

Thanks for the quick respond, seems to be able to point out region from parameters.

+@
I also found similar parameters on verify_revision_is_deployed command.
Although, this command does not includes description about region parameters, but wondering was it on purpose.

 DEPLOYMENTS=$(aws ecs describe-services \
      --profile "${ORB_STR_PROFILE_NAME}" \
      --cluster "$ORB_STR_CLUSTER_NAME" \
      --services "${ORB_STR_SERVICE_NAME}" \
      --region "${AWS_DEFAULT_REGION}" \
      --output text \
      --query 'services[0].deployments[].[taskDefinition, status]' \
      "$@")
  NUM_DEPLOYMENTS=$(aws ecs describe-services \
      --profile "${ORB_STR_PROFILE_NAME}" \
      --cluster "$ORB_STR_CLUSTER_NAME" \
      --services "${ORB_STR_SERVICE_NAME}" \
      --region "${AWS_DEFAULT_REGION}" \
      --output text \
      --query 'length(services[0].deployments)' \
      "$@")
  TARGET_REVISION=$(aws ecs describe-services \
      --profile "${ORB_STR_PROFILE_NAME}" \
      --cluster "$ORB_STR_CLUSTER_NAME" \
      --services "${ORB_STR_SERVICE_NAME}" \
      --region "${AWS_DEFAULT_REGION}" \
      --output text \
      --query "services[0].deployments[?taskDefinition==\`$ORB_STR_TASK_DEF_ARN\` && runningCount == desiredCount && (status == \`PRIMARY\` || status == \`ACTIVE\`)][taskDefinition]" \
      "$@")

@marboledacci
Copy link
Contributor

The initial design of the orb was to use the environment variables for the region. For the update_service command there was a recent addition of the parameter to solve some specific situation and that's why it't the only having it.

@nanophate
Copy link

nanophate commented Sep 30, 2024

Hi @marboledacci

Thanks for working on this issue ✨

Support are receiving request from user that it would be beneficial to be able to pass on pipeline parameters like the other command. Will the team able to also apply it for update_task_definition command which is calling src/scripts/get_prev_task.sh as well?

PREVIOUS_TASK_DEFINITION="$(aws ecs describe-task-definition \
    --task-definition "${ECS_TASK_DEFINITION_NAME}" \
    --include TAGS --profile "${ORB_STR_PROFILE_NAME}" \
    --region "${AWS_DEFAULT_REGION}" "$@")"

https://github.com/CircleCI-Public/aws-ecs-orb/blob/master/src/scripts/get_prev_task.sh#L20C173-L20C191

@marboledacci
Copy link
Contributor

Hi @nanophate I'm working on an update for that. The idea is to standardize it and let all the commands and jobs using the region parameter.

@marboledacci
Copy link
Contributor

Version 6.0.0 now has a region parameter for all the jobs and commands. I'm going to close this issue.

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

No branches or pull requests

3 participants