Open timakamystery opened 1 year ago
@timakamystery it's a list, you have to run through the subnet_ids with a [count.index] like this:
on line 32 (if you are doing is just like @ned1313) in resources.tf -
subnet_id = data.tfe_outputs.networking.nonsensitive_values.public_subnets[count.index]
https://github.com/timakamystery/globo-webapp/blob/tfe-outputs/resources.tf
│ Error: Unsupported attribute │ │ on security_groups.tf line 23, in resource "aws_security_group" "webapp_http_inbound_sg": │ 23: vpc_id = data.tfe_outputs.networking.nonsensitive_values.vpc_id │ ├──────────────── │ │ data.tfe_outputs.networking.nonsensitive_values is object with no attributes │ │ This object does not have an attribute named "vpc_id".
tfe = { source = "hashicorp/tfe" version = "= 0.47.0" }
`diff --git a/datasources.tf b/datasources.tf index bafe7b0..888c009 100644 --- a/datasources.tf +++ b/datasources.tf @@ -4,4 +4,9 @@
data "aws_ssm_parameter" "amzn2_linux" { name = "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2" +} + +data "tfe_outputs" "networking" {
workspace = var.tfe_workspace_name } \ No newline at end of file diff --git a/resources.tf b/resources.tf index f3ab76d..5272bf0 100644 --- a/resources.tf +++ b/resources.tf @@ -26,10 +26,10 @@ locals { ##################################################################################
resource "aws_instance" "main" {
subnets = data.tfe_outputs.networking.nonsensitive_values.public_subnets
enable_deletion_protection = false
@@ -120,7 +120,7 @@ resource "aws_lb_target_group" "main" { port = 80 target_type = "instance" protocol = "HTTP"
vpc_id = var.vpc_id
vpc_id = data.tfe_outputs.networking.nonsensitive_values.vpc_id }
resource "aws_alb_target_group_attachment" "main" { diff --git a/security_groups.tf b/security_groups.tf index 9419606..9459c41 100644 --- a/security_groups.tf +++ b/security_groups.tf @@ -20,7 +20,7 @@ resource "aws_security_group" "webapp_http_inbound_sg" { cidr_blocks = ["0.0.0.0/0"] }
vpc_id = var.vpc_id
vpc_id = data.tfe_outputs.networking.nonsensitive_values.vpc_id
tags = local.common_tags } @@ -36,7 +36,7 @@ resource "aws_security_group" "webapp_ssh_inbound_sg" { cidr_blocks = [var.ip_range] }
vpc_id = var.vpc_id
vpc_id = data.tfe_outputs.networking.nonsensitive_values.vpc_id
tags = local.common_tags } @@ -52,7 +52,7 @@ resource "aws_security_group" "webapp_outbound_sg" { cidr_blocks = ["0.0.0.0/0"] }
vpc_id = var.vpc_id
vpc_id = data.tfe_outputs.networking.nonsensitive_values.vpc_id
tags = local.common_tags } \ No newline at end of file diff --git a/terraform.tf b/terraform.tf index 0b2278d..ac83b91 100644 --- a/terraform.tf +++ b/terraform.tf @@ -4,5 +4,9 @@ terraform { source = "hashicorp/aws" version = "~>5.0" }
tfe = {
source = "hashicorp/tfe"
version = "~>0.49.2"
} } } \ No newline at end of file diff --git a/variables.tf b/variables.tf index b1ef070..1f042b4 100644 --- a/variables.tf +++ b/variables.tf @@ -37,14 +37,12 @@ variable "api_key" { description = "(Required) API key for web app to talk to SaaS platform." }
-variable "public_subnets" {
-variable "vpc_id" { +variable "tfe_workspace_name" { type = string
when doing terraform plan data.tfe_outputs.networking.nonsensitive_values.vpc_id basically is not found. comparing w/the complete code in m9 - it has no diff. also tried. init, then plan from there, - same error. tried both latest 0.49.2 and 0.47.0 of tfe provider, no diff