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_arn
property tonull
does this make theassume_role
block ineffective? (ie: the same as not being there) - If the
assume_role
block does have an impact, even when therole_arn
value isnull
, how can I completely remove it whenvar.islocal
istrue
?
I have considered a dynamic block but I'm not sure how to structure it.