@ $ tf validate
╷
│ Error: Provider configuration not present
│
│ To work with module.dev.aws_instance.prometheus its original provider configuration at
│ module.dev.provider["registry.terraform.io/hashicorp/aws"].dev is required, but it has been removed. This occurs
│ when a provider configuration is removed while objects created by that provider still exist in the state. Re-add
│ the provider configuration to destroy module.dev.aws_instance.prometheus, after which you can remove the provider
│ configuration again.
╵
Last active
May 26, 2021 04:13
-
-
Save wwalker/868d72a1223cd5c8864b02bb42ce937c to your computer and use it in GitHub Desktop.
multiple aws providers - HOW?????
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
required_version = ">= 0.13" | |
required_providers { | |
aws = { | |
source = "hashicorp/aws", | |
version = "~> 3.10" | |
} | |
} | |
} | |
### Resources | |
resource "aws_instance" "prometheus" { | |
ami = data.aws_ami.default.id | |
provider = aws.dev | |
instance_type = var.instance_type | |
subnet_id = data.aws_subnet.private.id | |
key_name = "ec2-user" | |
vpc_security_group_ids = [ | |
data.aws_security_group.linux_admin.id | |
] | |
iam_instance_profile = "prometheus" | |
monitoring = true | |
user_data = data.template_file.userdata.rendered | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
required_version = ">= 0.13" | |
required_providers { | |
aws = { | |
source = "hashicorp/aws", | |
version = "~> 3.10" | |
} | |
} | |
} | |
### Providers | |
provider "aws" { | |
region = "us-east-2" | |
alias = "staging" | |
} | |
provider "aws" { | |
alias = "dev" | |
region = "us-west-2" | |
} | |
# module | |
module "dev" { | |
source = "./ec2" | |
providers = { | |
aws = aws.dev | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment