I have two modules which Main.tf calls these two modules one after another.
first module is for creating IAM roles and second one to create aws glue jobs. I need to pass ARN number of a specific role created in first module to second module to create a glue job.
this is main.tf
# DataLake IAM Roles/Policies
module "iam_Policies"{
source = "./modules/iam/policies"
}
# DataLake Glue Jobs
module "glue_jobs"{
source = "./modules/glue/jobs"
}
This is main.tf for iam_policies module
resource "aws_iam_role" "AWSServiceRoleForRedshift" {
name = "AWSServiceRoleForRedshift"
path = "/"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Sid = ""
Principal = {
Service = "redshift.amazonaws.com"
}
},
]
})
}
I need to pass ARN number of role named “AWSServiceRoleForRedshift” to module glue_jobs.
I tried:
ARN_number = module.iam_Policies.aws_iam_role.AWSServiceRoleForRedshift.arn
but it doesn’t work.
any help apprecited if you know how to do this.
Thanks.