Skip to content

Instantly share code, notes, and snippets.

@xuqingfeng
Last active April 16, 2019 09:07
Show Gist options
  • Save xuqingfeng/de5d4abc6f38a78e01c2ed15aab73776 to your computer and use it in GitHub Desktop.
Save xuqingfeng/de5d4abc6f38a78e01c2ed15aab73776 to your computer and use it in GitHub Desktop.
# inside 'common' folder
output "vpc-id" {
value = "${alicloud_vpc.default.id}"
}
# fetch data from common state - https://www.terraform.io/docs/providers/terraform/d/remote_state.html
data "terraform_remote_state" "common" {
backend = "local"
config = {
path = "../common/terraform.tfstate"
}
}
resource "alicloud_security_group" "db" {
name = "${var.db-security-group-name}"
vpc_id = "${data.terraform_remote_state.common.vpc-id}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment