Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported attribute at m7 tfe_outputs commit plan #31

Open
timakamystery opened this issue Oct 17, 2023 · 1 comment
Open

Unsupported attribute at m7 tfe_outputs commit plan #31

timakamystery opened this issue Oct 17, 2023 · 1 comment

Comments

@timakamystery
Copy link

timakamystery commented Oct 17, 2023

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" {

  • organization = var.tfe_organization
  • 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" {

  • count = length(var.public_subnets)
  • count = length(data.tfe_outputs.networking.nonsensitive_values.public_subnets)
    ami = nonsensitive(data.aws_ssm_parameter.amzn2_linux.value)
    instance_type = var.instance_type
  • subnet_id = var.public_subnets[count.index]
  • subnet_id = data.tfe_outputs.networking.nonsensitive_values.public_subnets[count.index]
    vpc_security_group_ids = [
    aws_security_group.webapp_http_inbound_sg.id,
    aws_security_group.webapp_ssh_inbound_sg.id,
    @@ -97,7 +97,7 @@ resource "aws_lb" "main" {
    internal = false
    load_balancer_type = "application"
    security_groups = [aws_security_group.webapp_http_inbound_sg.id]
  • subnets = var.public_subnets
  • 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" {

  • type = list(string)
  • description = "(Required) List of subnet IDs for EC2 instance deployments."
    +variable "tfe_organization" {
  • type = string
  • description = "(Required) TFE Organization to use for remote state."
    }

-variable "vpc_id" {
+variable "tfe_workspace_name" {
type = string

  • description = "(Required) VPC ID of VPC for application deployment."
  • description = "(Required) TFE Workspace Name to use for remote state."
    }`

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

image

@mistwire
Copy link

@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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants