Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Sending custom variables deploying at AWS?

Ricardo Souza June 6, 2023

Hello,

I am working on a project, we have 4 environments ( 2 Own Linux and 2 AWS ). Bitbucket variables are being passed to our 2 own Linux env and not being passed to AWS.

How do I pass custom variables to AWS (BETA and Live branches) ? 

 

My last deploy was at Beta and line 118 ( 

ENVIRONMENT_NAME: $ENVIRONMENT_NAME) wasn't not sent. I made an endpoint to get it's value and it returns wrong value.

Can anyone help me please?

 

My pipeline here https://www.paste.org/125456 

 

Thanks

2 answers

0 votes
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 9, 2023

@Ricardo Souza . Thanks for your question.
According to schema

- pipe: atlassian/aws-ecs-deploy:1.7.0
  variables:
    AWS_ACCESS_KEY_ID: '<string>' # Optional if already defined in the context.
    AWS_SECRET_ACCESS_KEY: '<string>' # Optional if already defined in the context.
    AWS_DEFAULT_REGION: '<string>' # Optional if already defined in the context.
    AWS_OIDC_ROLE_ARN: "<string>" # Optional by default. Required for OpenID Connect (OIDC) authentication.
    CLUSTER_NAME: '<string>'
    SERVICE_NAME: '<string>'
    TASK_DEFINITION: '<string>' # Optional
    FORCE_NEW_DEPLOYMENT: '<boolean>' # Optional
    # WAIT: '<boolean>' # Optional 
    # DEBUG: '<string>' # Optional

Pipe aws-ecs-deploy does not support ENVIRONMENT_NAME: $ENVIRONMENT_NAME variable (or any other variables not defined in schema).

Maybe you should try to pass your environment variables to task definitions: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-definition-template.html and than set a path to the task definition json file with TASK_DEFINITION variable when using this pipe.

Regards, Igor

Ricardo Souza June 9, 2023

Hello @Igor Stoyanov , I didn't understand how can I solve my problem.

Is it possible use a .env? Because this pipeline sends ALL variables I need to other branches ( develop and master). 

Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 9, 2023

@Ricardo Souza  pipeline and pipe are different things.
In your example you send variables from the pipeline to the pipe via this code:

                - pipe: atlassian/aws-ecs-deploy:1.0.6
                  variables:
                    AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
                    AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
                    AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
                    ENVIRONMENT_NAME: $ENVIRONMENT_NAME
                    CLUSTER_NAME: "APP-default"
                    SERVICE_NAME: "APP-online-beta"
                    TASK_DEFINITION: "task.json"

but the pipe does not use your ENVIRONMENT_NAME variable, because this variable is not defined in schema.
Instead you could try to update your task-definition file (task.json in your case) which allows you to update your environments on AWS side.
If i correctly understand, here we have: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-definition-template.html ,  
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/taskdef-envfiles.html 
this block, which you could fill with your environment variables and save the result as task.json:


{ "family": "",
"containerDefinitions": [
{ "name": "",
"image": "",
...
"environment": [
{ "name": "variable",
"value": "value" } ],
... } ]
, ... }
0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 8, 2023

Hello @Ricardo Souza and thank you for reaching out to Community! 

I see you have opened a support ticket with us related to this issue and one of our support engineers is already working with you on that case.

To avoid any confusions that may arise from discussing the case in two different places, we recommend focusing the discussion on the support ticket. Once the ticket is closed, if you feel comfortable, feel free to share the solution with the rest of the community here :)

Thank you, @Ricardo Souza !

Patrik S

Ricardo Souza June 8, 2023

Weird. Last time I opened a ticket at Atlassian,  you ( from support)requested me to ask in the community.

 

I just want to know how to fix my pipeline to send custom variables to AWS.

 

Thanks

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events