You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I'm creating ElasticBeanStalk using bitbucket pipeline and terraform.
I have 3 environment, and each environment has 3 regions under the same account.
I have also incorporated the IAM role and permission within the same pipeline. When trying to run pipeline for different region, it failed in IAM role & permission creation with an error resource already exists.
I want to use the pipeline variable to check if the IAM role/permission needs to create? If the value is True then it should run the script.
I studied the bitbucket if condition, but it won't execute the terraform script,
if $CREATE_ROLE; then
- cd createIamAcess
- terraform init -backend-config="bucket=$s3_Backend_Bucket_Name" -backend-config="key=$s3_Backend_StateFile_Location" -reconfigure
- terraform plan
- terraform apply -input=false -auto-approve
Can anyone please advise, how to use the terraform script within the if condition? or any other alternate option.
You can try using bash's implicit if:
[[ ! -z "$CREATE_ROLE" ]] && terraform init -backend-config="bucket=$s3_Backend_Bucket_Name" -backend-config="key=$s3_Backend_StateFile_Location" -reconfigure
Hope that helps
Thank you for the suggesstion, it really helps. I have modified the script as follows: