I have a provider block which I want to give an assume_role property but only if it is not running on my local machine.
I have defined a variable islocal in all the environment .tfvars files, with only the local file having the value true.
This is the provider block:
provider "aws" {
region = var.region1
profile = var.islocal == true ? "default" : null # ONLY USED LOCALLY
assume_role { # NOT TO BE USED LOCALLY
role_arn = var.terraform_execution_role
}
}
Questions:
- If I set the
role_arnproperty tonulldoes this make theassume_roleblock ineffective? (ie: the same as not being there) - If the
assume_roleblock does have an impact, even when therole_arnvalue isnull, how can I completely remove it whenvar.islocalistrue?
I have considered a dynamic block but I'm not sure how to structure it.