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.
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.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.