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

[Bug]: Error: Incompatible Types (aws_appfabric_app_authorization) #41014

Closed
takahiro-oda-paypay opened this issue Jan 20, 2025 · 2 comments
Closed
Labels
bug Addresses a defect in current functionality. service/appfabric Issues and PRs that pertain to the appfabric service.

Comments

@takahiro-oda-paypay
Copy link

takahiro-oda-paypay commented Jan 20, 2025

Terraform Core Version

1.9.9

AWS Provider Version

5.83.0

Affected Resource(s)

aws_appfabric_app_authorization

Expected Behavior

create aws_appfabric_app_authorization

Actual Behavior

│ Error: Incompatible Types
│ 
│   with module.Box["xxx"].aws_appfabric_app_authorization.this,
│   on appfabric.tf line 5, in resource "aws_appfabric_app_authorization" "this":
│    5: resource "aws_appfabric_app_authorization" "this" {
│ 
│ An unexpected error occurred while expanding configuration. This is always
│ an error in the provider. Please report the following to the provider
│ developer:
│ 
│ Expanding
│ "github.com/hashicorp/terraform-provider-aws/internal/service/appfabric.credentialModel"
│ returned nil.

Got this error.

Relevant Error/Panic Output Snippet

provided above

Terraform Configuration Files

resource "aws_appfabric_app_bundle" "this" {
  tags = var.tags
}

resource "aws_appfabric_app_authorization" "this" {
  depends_on     = [aws_appfabric_app_bundle.this]
  app            = var.app_name
  app_bundle_arn = aws_appfabric_app_bundle.this.arn
  auth_type      = var.auth_type

  dynamic "credential" {
    for_each = var.credentials
    content {
      dynamic "oauth2_credential" {
        for_each = contains(keys(credential), "oauth2_credential") ? [credential.oauth2_credential] : []
        content {
          client_id     = sensitive(oau.client_id)
          client_secret = sensitive(oau.client_secret)
        }
      }
      dynamic "api_key_credential" {
        for_each = contains(keys(credential), "api_key_credential") ? [credential.api_key_credential] : []
        content {
          api_key = sensitive(api.api_key)
        }
      }
    }
  }

  dynamic "tenant" {
    for_each = var.tenants != null ? [var.tenants[0]] : []
    content {
      tenant_display_name = tenant.value.tenant_display_name
      tenant_identifier   = tenant.value.tenant_identifier
    }
  }
}

resource "aws_appfabric_app_authorization_connection" "this" {
  depends_on            = [aws_appfabric_app_bundle.this]
  app_authorization_arn = aws_appfabric_app_authorization.this.arn
  app_bundle_arn        = aws_appfabric_app_bundle.this.arn

  dynamic "auth_request" {
    for_each = var.auth_requests != null && length(var.auth_requests) > 0 ? [var.auth_requests[0]] : []
    iterator = auth
    content {
      code         = lookup(auth.value, "code", "")
      redirect_uri = lookup(auth.value, "redirect_uri", "")
    }
  }
}

resource "aws_appfabric_ingestion" "this" {
  depends_on     = [aws_appfabric_app_authorization_connection.this]
  app            = var.app_name
  app_bundle_arn = aws_appfabric_app_bundle.this.arn
  tenant_id      = var.tenant_id
  ingestion_type = var.ingestion_type
  tags           = var.tags
}

resource "aws_appfabric_ingestion_destination" "this" {
  app_bundle_arn = aws_appfabric_ingestion.this.app_bundle_arn
  ingestion_arn  = aws_appfabric_ingestion.this.arn

  dynamic "destination_configuration" {
    for_each = var.destination_configurations
    iterator = des
    content {
      dynamic "audit_log" {
        for_each = des.value.destination_configuration.audit_log
        iterator = audit
        content {
          dynamic "destination" {
            for_each = audit.value.destination
            iterator = dest
            content {
              dynamic "s3_bucket" {
                for_each = lookup(dest.value, "s3_bucket", [])
                content {
                  bucket_name = var.s3_bucket
                  prefix      = lookup(dest.value.s3_bucket, "prefix", "")
                }
              }
            }
          }
        }
      }
    }
  }

  dynamic "processing_configuration" {
    for_each = var.processing_configurations
    iterator = pro
    content {
      dynamic "audit_log" {
        for_each = pro.value.processing_configuration.audit_log
        iterator = audit
        content {
          format = lookup(audit.value, "format", "")
          schema = lookup(audit.value, "schema", "")
        }
      }
    }
  }
}

local {
 xxx_tenant_id = xxxxxxxx
  appfabric = {
    xxx = {
      environment = "xx”x
      credentials = [
        {
          oauth2_credential = {
            client_id     = jsondecode(data.aws_secretsmanager_secret_version.xxx.secret_string)["id"]
            client_secret = jsondecode(data.aws_secretsmanager_secret_version.xxx.secret_string)["secret"]
          }
        }
      ]
      tenants = [{ tenant_display_name = “xxx”, tenant_identifier = local.xxx_tenant_id }]
    }
    yyy = {
      environment = " yyy"
      credentials = [
        {
          oauth2_credential = {
            client_id     = jsondecode(data.aws_secretsmanager_secret_version.xxx.secret_string)[" yyy-id"]
            client_secret = jsondecode(data.aws_secretsmanager_secret_version.xxx.secret_string)[" yyy-secret"]
          }
        }
      ]
      tenants = [{ tenant_display_name = "yyy”, tenant_identifier = local. xxx_tenant_id}]
    }
  }
  destination_configurations = [{
    destination_configuration = {
      audit_log = [{
        destination = [{
          s3_bucket = { prefix = local.xxx_tenant_id }
        }]
      }]
    }
  }]
  processing_configurations = [{
    processing_configuration = {
      audit_log = [{
        format = "parquet"
        schema = "ocsf"
      }]
    }
  }]
}

terraform {
  required_version = "1.9.9"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "5.803.0"
    }
  }
}
provider "aws" {
  region = "ap-northeast-1"
}

module "Box" {
  source                     = "."
  for_each                   = local.appfabric
  app_name                   = "BOX"
  credentials                = each.value.credentials
  tenants                    = each.value.tenants
  tenant_id                  = local.xxx_tenant_id
  ingestion_type             = "auditLog"
  auth_type                  = "oauth2"
  processing_configurations  = local.processing_configurations
  destination_configurations = local.destination_configurations
  s3_bucket                  = data.aws_s3_bucket.security_detection.bucket
  tags                       = { Environment = each.value.environment }
}

Steps to Reproduce

terraform init
terraform apply

Debug Output

N/A

Panic Output

N/A

Important Factoids

N/A

References

N/A

Would you like to implement a fix?

No

@takahiro-oda-paypay takahiro-oda-paypay added the bug Addresses a defect in current functionality. label Jan 20, 2025
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added service/appfabric Issues and PRs that pertain to the appfabric service. needs-triage Waiting for first response or review from a maintainer. labels Jan 20, 2025
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Jan 23, 2025
Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/appfabric Issues and PRs that pertain to the appfabric service.
Projects
None yet
Development

No branches or pull requests

2 participants