Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can I call a pipeline step for each directory in repository?

Adam Wilson April 25, 2025

I am using the atlassian/aws-lambda-deploy step in my pipeline, but I have a lot of lambda functions, so I was looking for a way to run the step for each directory.

Something like:

for dir in *; do
step:
     script:
     - pipe: atlassian/aws-lambda-deploy
done

I am currently hard coding each step, but would like to iterate through all the directories instead. 

2 answers

0 votes
John Emmanuel
Contributor
April 29, 2025

Hi,

What you are asking for is not possible in Bitbucket pipelines YAML syntax.

However, the best option would be to create a custom Bash script that can iterate through all your directories to deploy your functions. You can use AWS CLI commands to deploy code to Lambda. It even has a wait function that can wait till your function is deployed/updated so that you can perform things like map an alias to the version, etc.

Adam Wilson April 29, 2025

@John Emmanuel I appreciate the response. We have written just such a script, but while I iterate through the folders I can automate all the steps, I was trying to avoid recreating the more advanced capabilities built into the atlassian/aws-lambda-deploy pipe, such as the IODC authentication.

John Emmanuel
Contributor
April 29, 2025

OIDC is accessible within the script itself. You need to enable
odic: true in the step config and use the following commands to leverage OIDC roles without using AWS access/secret keys.

 - step:
name: Step with OIDC
oidc: true
script:
- >-
export AWS_REGION=<region> &&
export AWS_ROLE_ARN=$OIDC_ROLE_ARN &&
export AWS_WEB_IDENTITY_TOKEN_FILE=$(pwd)/web-identity-token &&
echo $BITBUCKET_STEP_OIDC_TOKEN > $(pwd)/web-identity-token
- aws s3 ls #Other aws commands or ./script.sh , all will use oidc.

Ensure you set the proper role ARN to the OIDC_ROLE_ARN variable in pipeline variables.

0 votes
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 28, 2025

G'day, @Adam Wilson 

Welcome to the community!

I believe a Custom pipe is the way to go here. Since you will be using it in multiple directories, you can create a custom pipe to run the script in all your directories and use it on all your steps.

Regards,
Syahrul

 

Adam Wilson April 29, 2025

@Syahrul do you know if there is a way to pull the atlassian/aws-lambda-deploy into a custom pipe so that I can leverage all the features that the AWS team has made available there?

Suggest an answer

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

Atlassian Community Events