Reputation: 78244
I have 2 modules ..booted a VPC and added some s3 buckets with output saved in s3. I then added another module re init then tried to plan
The new module looks like the below. I need to use data to get the vpc_id.
provider "aws" {
region = var.region
shared_credentials_file = "$HOME/.aws/credentials"
profile = "terraform"
}
terraform {
backend "s3" {
profile = "terraform"
bucket = var.remote_state_bucket
key = var.remote_state_key
region = var.region
}
}
data "terraform_remote_state" "network_configuration" {
backend = "s3"
config = {
bucket = var.remote_state_bucket
key = var.remote_state_key
region = var.region
}
}
When I run
terraform plan -var-file="test.tfvars"
I get the below error as a result of the terraform_remote_state block. I remove then the plans works.
Error: AccessDenied: Access Denied
status code: 403, request id: ZRTM92CVDQFRBF9T, host id: 0HYGuPq9Q7skZLtXvdR3mD6657g4fqUaQQNf2jP2GRcLx1vTxkYhFtyKAiTTLRBrEwECnPf0Y9A=
Why? I don't get it? How do I resolve?
Upvotes: 0
Views: 633
Reputation: 238131
You should add profile
to your config
:
data "terraform_remote_state" "network_configuration" {
backend = "s3"
config = {
bucket = var.remote_state_bucket
key = var.remote_state_key
region = var.region
profile = "terraform"
}
}
Upvotes: 2