Hi All,
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
echo true
- 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
fi
Can anyone please advise, how to use the terraform script within the if condition? or any other alternate option.
Regards,
Nikhil Shah
Hey @Nikhil
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
Hi,
Thank you for the suggesstion, it really helps. I have modified the script as follows:
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.