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

WAFV2 with Go Fails to generate code for imported resource #11552

Open
alexandr-x-ursul opened this issue Dec 6, 2022 · 2 comments
Open

WAFV2 with Go Fails to generate code for imported resource #11552

alexandr-x-ursul opened this issue Dec 6, 2022 · 2 comments
Labels
area/codegen SDK-gen, program-gen, convert kind/bug Some behavior is incorrect or out of spec language/go

Comments

@alexandr-x-ursul
Copy link

alexandr-x-ursul commented Dec 6, 2022

What happened?

My goal was to import and codify an AWS WAF resource. The resource was successfully imported, however the code generation for it failed with a lengthy error, which I'm going to attach as a file for brevity.

Steps to reproduce

$ pulumi import aws-native:wafv2:WebACL main-web-acl-prod 'xxx|xxx|REGIONAL' --parent main='urn:xxx...'
Previewing import (xxx/prod)

     Type                           Name               Plan
     pulumi:pulumi:Stack            xxx-prod
     └─ xxx          main
 =      └─ aws-native:wafv2:WebACL  main-web-acl-prod  import

Resources:
= 1 to import
51 unchanged

Do you want to perform this import? yes
Importing (xxx/prod)

     Type                           Name               Status
     pulumi:pulumi:Stack            xxx-prod
     └─ xxx          main
 =      └─ aws-native:wafv2:WebACL  main-web-acl-prod  imported (5s)

Resources:
= 1 imported
51 unchanged

Duration: 6s

error: internal error: Warning: undefined variable main

Expected Behavior

After the successful import, code representing the imported resource should have been generated.

Actual Behavior

Pulumi crashed.

Output of pulumi about

CLI
Version 3.48.0
Go Version go1.19.2
Go Compiler gc

Plugins
NAME VERSION
aws 5.21.1
aws-native 0.43.0
go unknown

Host
OS ubuntu
Version 20.04
Arch x86_64

This project is written in go: executable='/usr/local/go/bin/go' version='go version go1.19.2 linux/amd64'

Found no pending operations associated with xxx/prod

Backend
Name pulumi.com
URL https://app.pulumi.com/xxx
User xxx
Organizations xxx, xxx

Dependencies:
NAME VERSION
github.com/pulumi/pulumi-aws-native/sdk 0.43.0
github.com/pulumi/pulumi-aws/sdk/v5 5.21.1
github.com/pulumi/pulumi/sdk/v3 3.48.0
pkg/database 0.0.0-00010101000000-000000000000
pkg/environment 0.0.0-00010101000000-000000000000
pkg/nfs 0.0.0-00010101000000-000000000000

Additional context

I first attempted to use AWS Classic provider for this, but I unfortunately reached a dead end as reported here: pulumi/pulumi-aws#2250

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@alexandr-x-ursul alexandr-x-ursul added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Dec 6, 2022
@alexandr-x-ursul alexandr-x-ursul changed the title WAFV2 Fails to generate code for imported resource WAFV2 with Go Fails to generate code for imported resource Dec 6, 2022
@danielrbradley
Copy link
Member

danielrbradley commented Dec 6, 2022

Just pulling the error message apart, we're getting a failure when trying to generate the code to add to the program

Error: cannot assign expression of type

tuple(
  object(
    {
      action = object({count = object({})}),
      name = string,
      priority = cty.NumberIntVal(0),
      ruleLabels = tuple(object({name = string})),
      statement = object(
        {
          orStatement = object(
            {
              statements = tuple(
                object(
                  {sizeConstraintStatement = object({comparisonOperator = string, fieldToMatch = object({body = object({oversizeHandling = string})}), size = cty.NumberIntVal(8000), textTransformations = tuple(object({priority = cty.NumberIntVal(0), type = string}))})}
                ),
                object(
                  {sizeConstraintStatement = object({comparisonOperator = string, fieldToMatch = object({cookies = object({matchPattern = object({all = object({}), excludedCookies = tuple(), includedCookies = tuple()}), matchScope = string, oversizeHandling = string})}), size = cty.NumberIntVal(8000), textTransformations = tuple(object({priority = cty.NumberIntVal(0), type = string}))})}
                ),
                object(
                  {sizeConstraintStatement = object({comparisonOperator = string, fieldToMatch = object({headers = object({matchPattern = object({all = object({}), excludedHeaders = tuple(), includedHeaders = tuple()}), matchScope = string, oversizeHandling = string})}), size = cty.NumberIntVal(8000), textTransformations = tuple(object({priority = cty.NumberIntVal(0), type = string}))})}
                )
              )
            }
          )
        }
      ),
      visibilityConfig = object({cloudWatchMetricsEnabled = cty.True, metricName = string, sampledRequestsEnabled = cty.True})
    }
  ),
  object(
    {
      action = object({count = object({})}),
      name = string, priority = cty.NumberIntVal(1),
      ruleLabels = tuple(object({name = string})),
      statement = object({andStatement = object({statements = tuple(object({labelMatchStatement = object({key = string, scope = string})}), object({byteMatchStatement = object({fieldToMatch = object({uriPath = object({})}), positionalConstraint = string, searchString = string, searchStringBase64 = string, textTransformations = tuple(object({priority = cty.NumberIntVal(0), type = string}))})}), object({notStatement = object({statement = object({sizeConstraintStatement = object({comparisonOperator = string, fieldToMatch = object({singleQueryArgument = object({name = string})}), size = cty.NumberIntVal(1), textTransformations = tuple(object({priority = cty.NumberIntVal(0), type = string}))})})})}))})}),
      visibilityConfig = object({cloudWatchMetricsEnabled = cty.True, metricName = string, sampledRequestsEnabled = cty.True})}
  ),
  object(
    {action = object({count = object({})}), name = string, priority = cty.NumberIntVal(2), ruleLabels = tuple(object({name = string})), statement = object({andStatement = object({statements = tuple(object({notStatement = object({statement = object({byteMatchStatement = object({fieldToMatch = object({uriPath = object({})}), positionalConstraint = string, searchString = string, searchStringBase64 = string, textTransformations = tuple(object({priority = cty.NumberIntVal(0), type = string}))})})})}), object({labelMatchStatement = object({key = string, scope = string})}))})}), visibilityConfig = object({cloudWatchMetricsEnabled = cty.True, metricName = string, sampledRequestsEnabled = cty.True})}
  ),
  object(
    {action = object({allow = object({})}), name = string, priority = cty.NumberIntVal(3), ruleLabels = tuple(), statement = object({iPSetReferenceStatement = object({arn = string})}), visibilityConfig = object({cloudWatchMetricsEnabled = cty.True, metricName = string, sampledRequestsEnabled = cty.True})}
  ),
  object(
    {action = object({block = object({})}), name = string, priority = cty.NumberIntVal(4), ruleLabels = tuple(), statement = object({iPSetReferenceStatement = object({arn = string})}), visibilityConfig = object({cloudWatchMetricsEnabled = cty.True, metricName = string, sampledRequestsEnabled = cty.True})}
  ),
  object(
    {action = object({allow = object({})}), name = string, priority = cty.NumberIntVal(5), ruleLabels = tuple(), statement = object({iPSetReferenceStatement = object({arn = string})}), visibilityConfig = object({cloudWatchMetricsEnabled = cty.True, metricName = string, sampledRequestsEnabled = cty.False})}
  ),
  object(
    {name = string, overrideAction = object({none = object({})}), priority = cty.NumberIntVal(6), ruleLabels = tuple(), statement = object({managedRuleGroupStatement = object({excludedRules = tuple(), managedRuleGroupConfigs = tuple(), name = string, vendorName = string})}), visibilityConfig = object({cloudWatchMetricsEnabled = cty.True, metricName = string, sampledRequestsEnabled = cty.True})}
  ),
  object(
    {action = object({block = object({})}), name = string, priority = cty.NumberIntVal(7), ruleLabels = tuple(), statement = object({andStatement = object({statements = tuple(object({byteMatchStatement = object({fieldToMatch = object({queryString = object({})}), positionalConstraint = string, searchString = string, searchStringBase64 = string, textTransformations = tuple(object({priority = cty.NumberIntVal(0), type = string}))})}), object({notStatement = object({statement = object({byteMatchStatement = object({fieldToMatch = object({uriPath = object({})}), positionalConstraint = string, searchString = string, searchStringBase64 = string, textTransformations = tuple(object({priority = cty.NumberIntVal(0), type = string}))})})})}))})}), visibilityConfig = object({cloudWatchMetricsEnabled = cty.True, metricName = string, sampledRequestsEnabled = cty.True})}
  ),
  object(
    {name = string, overrideAction = object({none = object({})}), priority = cty.NumberIntVal(8), ruleLabels = tuple(), statement = object({managedRuleGroupStatement = object({excludedRules = tuple(object({name = string}), object({name = string}), object({name = string}), object({name = string}), object({name = string}), object({name = string}), object({name = string}), object({name = string}), object({name = string}), object({name = string}), object({name = string}), object({name = string}), object({name = string}), object({name = string}), object({name = string}), object({name = string}), object({name = string}), object({name = string})), managedRuleGroupConfigs = tuple(), name = string, scopeDownStatement = object({andStatement = object({statements = tuple(object({notStatement = object({statement = object({regexMatchStatement = object({fieldToMatch = object({uriPath = object({})}), regexString = string, textTransformations = tuple(object({priority = cty.NumberIntVal(0), type = string}))})})})}), object({notStatement = object({statement = object({byteMatchStatement = object({fieldToMatch = object({uriPath = object({})}), positionalConstraint = string, searchString = string, searchStringBase64 = string, textTransformations = tuple(object({priority = cty.NumberIntVal(0), type = string}))})})})}), object({notStatement = object({statement = object({byteMatchStatement = object({fieldToMatch = object({uriPath = object({})}), positionalConstraint = string, searchString = string, searchStringBase64 = string, textTransformations = tuple(object({priority = cty.NumberIntVal(0), type = string}))})})})}))})}), vendorName = string})}), visibilityConfig = object({cloudWatchMetricsEnabled = cty.True, metricName = string, sampledRequestsEnabled = cty.True})}
  ),
  object(
    {action = object({block = object({})}), name = string, priority = cty.NumberIntVal(9), ruleLabels = tuple(object({name = string})), statement = object({orStatement = object({statements = tuple(object({byteMatchStatement = object({fieldToMatch = object({queryString = object({})}), positionalConstraint = string, searchString = string, searchStringBase64 = string, textTransformations = tuple(object({priority = cty.NumberIntVal(0), type = string}), object({priority = cty.NumberIntVal(1), type = string}))})}), object({byteMatchStatement = object({fieldToMatch = object({body = object({oversizeHandling = string})}), positionalConstraint = string, searchString = string, searchStringBase64 = string, textTransformations = tuple(object({priority = cty.NumberIntVal(0), type = string}))})}))})}), visibilityConfig = object({cloudWatchMetricsEnabled = cty.True, metricName = string, sampledRequestsEnabled = cty.True})}
  )
)

to location of type

union(
  list(
    union(
      object({action = union(none, object({allow = union(none, object({customRequestHandling = union(none, object({insertHeaders = union(list(union(object({name = union(output(string), string, annotated(0xc001a33700)), value = union(output(string), string, annotated(0xc001a33740))}, annotated(0xc001a336c0)), output(object({name = string, value = string}, annotated(0xc001a33780))), annotated(0xc001a337c0))), output(list(object({name = string, value = string}, annotated(0xc001a33780)))), annotated(0xc001a33800))}, annotated(0xc001a33680)), output(object({insertHeaders = list(object({name = string, value = string}, annotated(0xc001a33780)))}, annotated(0xc001a33840))), annotated(0xc001a33900))}, annotated(0xc001a33640)), output(object({customRequestHandling = union(none, object({insertHeaders = list(object({name = string, value = string}, annotated(0xc001a33780)))}, annotated(0xc001a33840)))}, annotated(0xc001a33940))), annotated(0xc00178e480)), block = union(none, object({customResponse = union(none, object({customResponseBodyKey = union(none, output(string), string, annotated(0xc001a33bc0)), responseCode = union(int, output(int), annotated(0xc001a33c00)), responseHeaders = union(list(union(object({name = union(output(string), string, annotated(0xc001a33700)), value = union(output(string), string, annotated(0xc001a33740))}, annotated(0xc001a336c0)), output(object({name = string, value = string}, annotated(0xc001a33780))), annotated(0xc001a33c40))), none, output(list(object({name = string, value = string}, annotated(0xc001a33780)))), annotated(0xc001a33d00))}, annotated(0xc001a33b00)), output(object({customResponseBodyKey = union(none, string), responseCode = int, responseHeaders = union(list(object({name = string, value = string}, annotated(0xc001a33780))), none)}, annotated(0xc001a33d40))), annotated(0xc001a33f00))}, annotated(0xc001a33ac0)), output(object({customResponse = union(none, object({customResponseBodyKey = union(none, string), responseCode = int, responseHeaders = union(list(object({name = string, value = string}, annotated(0xc001a33780))), none)}, annotated(0xc001a33d40)))}, annotated(0xc001a33f40))), annotated(0xc00178e540)), captcha = union(none, object({customRequestHandling = union(none, object({insertHeaders = union(list(union(object({name = union(output(string), string, annotated(0xc001a33700)), value = union(output(string), string, annotated(0xc001a33740))}, annotated(0xc001a336c0)), output(object({name = string, value = string}, annotated(0xc001a33780))), annotated(0xc001a337c0))), output(list(object({name = string, value = string}, annotated(0xc001a33780)))), annotated(0xc001a33800))}, annotated(0xc001a33680)), output(object({insertHeaders = list(object({name = string, value = string}, annotated(0xc001a33780)))}, annotated(0xc001a33840))), annotated(0xc00178e640))}, annotated(0xc00178e580)), output(object({customRequestHandling = union(none, object({insertHeaders = list(object({name = string, value = string}, annotated(0xc001a33780)))}, annotated(0xc001a33840)))}, annotated(0xc00178e680))), annotated(0xc00178e780)), count = union(none, object({customRequestHandling = union(none, object({insertHeaders = union(list(union(object({name = union(output(string), string, annotated(0xc001a33700)), value = union(output(string), string, annotated(0xc001a33740))}, annotated(0xc001a336c0)), output(object({name = string, value = string}, annotated(0xc001a33780))), annotated(0xc001a337c0))), output(list(object({name = string, value = string}, annotated(0xc001a33780)))), annotated(0xc001a33800))}, annotated(0xc001a33680)), output(object({insertHeaders = list(object({name = string, value = string}, annotated(0xc001a33780)))}, annotated(0xc001a33840))), annotated(0xc00178e880))}, annotated(0xc00178e7c0)), output(object({customRequestHandling = union(none, object({insertHeaders = list(object({name = string, value = string}, annotated(0xc001a33780)))}, annotated(0xc001a33840)))}, annotated(0xc00178e8c0))), annotated(0xc00178e9c0))}, annotated(0xc00178e3c0)), output(object({allow = union(none, object({customRequestHandling = union(none, object({insertHeaders = list(object({name = string, value = string}, annotated(0xc001a33780)))}, annotated(0xc001a33840)))}, annotated(0xc001a33940))), block = union(none, object({customResponse = union(none, object({customResponseBodyKey = union(none, string), responseCode = int, responseHeaders = union(list(object({name = string, value = string}, annotated(0xc001a33780))), none)}, annotated(0xc001a33d40)))}, annotated(0xc001a33f40))), captcha = union(none, object({customRequestHandling = union(none, object({insertHeaders = list(object({name = string, value = string}, annotated(0xc001a33780)))}, annotated(0xc001a33840)))}, annotated(0xc00178e680))), count = union(none, object({customRequestHandling = union(none, object({insertHeaders = list(object({name = string, value = string}, annotated(0xc001a33780)))}, annotated(0xc001a33840)))}, annotated(0xc00178e8c0)))}, annotated(0xc00178ea00))), annotated(0xc00178edc0)), captchaConfig = union(none, object({immunityTimeProperty = union(none, object({immunityTime = union(int, output(int), annotated(0xc001a33240))}, annotated(0xc001a33200)), output(object({immunityTime = int}, annotated(0xc001a33280))), annotated(0xc001a33340))}, annotated(0xc001a331c0)), output(object({immunityTimeProperty = union(none, object({immunityTime = int}, annotated(0xc001a33280)))}, annotated(0xc001a33380))), annotated(0xc00178ee80)), name = union(output(string), string, annotated(0xc00178eec0)), overrideAction = union(none, object({count = union(dynamic, none, output(dynamic), annotated(0xc00178efc0)), none = union(dynamic, none, output(dynamic), annotated(0xc00178f080))}, annotated(0xc00178ef00)), output(object({count = union(dynamic, none), none = union(dynamic, none)}, annotated(0xc00178f0c0))), annotated(0xc00178f200)), priority = union(int, output(int), annotated(0xc00178f240)), ruleLabels = union(list(union(object({name = union(output(string), string, annotated(0xc00178f2c0))}, annotated(0xc00178f280)), output(object({name = string}, annotated(0xc00178f300))), annotated(0xc00178f340))), none, output(list(object({name = string}, annotated(0xc00178f300)))), annotated(0xc00178f400)), statement = union(object({}, annotated(0xc00178f440)), output(object({}, annotated(0xc00178f4c0))), annotated(0xc001a29240)), visibilityConfig = union(object({cloudWatchMetricsEnabled = union(bool, output(bool), annotated(0xc001a292c0)), metricName = union(output(string), string, annotated(0xc001a29300)), sampledRequestsEnabled = union(bool, output(bool), annotated(0xc001a29340))}, annotated(0xc001a29280)), output(object({cloudWatchMetricsEnabled = bool, metricName = string, sampledRequestsEnabled = bool}, annotated(0xc001a29380))), annotated(0xc001a29440))}, annotated(0xc00178e380)), 
      output(object({action = union(none, object({allow = union(none, object({customRequestHandling = union(none, object({insertHeaders = list(object({name = string, value = string}, annotated(0xc001a33780)))}, annotated(0xc001a33840)))}, annotated(0xc001a33940))), block = union(none, object({customResponse = union(none, object({customResponseBodyKey = union(none, string), responseCode = int, responseHeaders = union(list(object({name = string, value = string}, annotated(0xc001a33780))), none)}, annotated(0xc001a33d40)))}, annotated(0xc001a33f40))), captcha = union(none, object({customRequestHandling = union(none, object({insertHeaders = list(object({name = string, value = string}, annotated(0xc001a33780)))}, annotated(0xc001a33840)))}, annotated(0xc00178e680))), count = union(none, object({customRequestHandling = union(none, object({insertHeaders = list(object({name = string, value = string}, annotated(0xc001a33780)))}, annotated(0xc001a33840)))}, annotated(0xc00178e8c0)))}, annotated(0xc00178ea00))), captchaConfig = union(none, object({immunityTimeProperty = union(none, object({immunityTime = int}, annotated(0xc001a33280)))}, annotated(0xc001a33380))), name = string, overrideAction = union(none, object({count = union(dynamic, none), none = union(dynamic, none)}, annotated(0xc00178f0c0))), priority = int, ruleLabels = union(list(object({name = string}, annotated(0xc00178f300))), none), statement = object({}, annotated(0xc00178f4c0)), visibilityConfig = object({cloudWatchMetricsEnabled = bool, metricName = string, sampledRequestsEnabled = bool}, annotated(0xc001a29380))}, annotated(0xc001a29480))),
      annotated(0xc001a29640)
    )
  ),
  none,
  output(
    list(
      object(
        {
          action = union(
            none, 
            object(
              {
                allow = union(none, object({customRequestHandling = union(none, object({insertHeaders = list(object({name = string, value = string}, annotated(0xc001a33780)))}, annotated(0xc001a33840)))}, annotated(0xc001a33940))),
                block = union(none, object({customResponse = union(none, object({customResponseBodyKey = union(none, string), responseCode = int, responseHeaders = union(list(object({name = string, value = string}, annotated(0xc001a33780))), none)}, annotated(0xc001a33d40)))}, annotated(0xc001a33f40))),
                captcha = union(none, object({customRequestHandling = union(none, object({insertHeaders = list(object({name = string, value = string}, annotated(0xc001a33780)))}, annotated(0xc001a33840)))}, annotated(0xc00178e680))),
                count = union(none, object({customRequestHandling = union(none, object({insertHeaders = list(object({name = string, value = string}, annotated(0xc001a33780)))}, annotated(0xc001a33840)))}, annotated(0xc00178e8c0)))
              },
              annotated(0xc00178ea00)
            )
          ),
          captchaConfig = union(none, object({immunityTimeProperty = union(none, object({immunityTime = int}, annotated(0xc001a33280)))}, annotated(0xc001a33380))),
          name = string,
          overrideAction = union(none, object({count = union(dynamic, none), none = union(dynamic, none)}, annotated(0xc00178f0c0))),
          priority = int,
          ruleLabels = union(list(object({name = string}, annotated(0xc00178f300))), none),
          statement = object({}, annotated(0xc00178f4c0)),
          visibilityConfig = object({cloudWatchMetricsEnabled = bool, metricName = string, sampledRequestsEnabled = bool}, annotated(0xc001a29380))
        }, annotated(0xc001a29480)
      )
    )
  ),
  annotated(0xc001a29700)
)

@danielrbradley
Copy link
Member

Transferring as this appears to be a Go program generation bug.

@alexandr-x-ursul if you inspect the code at the end of the error message, this might give you enough information to construct the code by hand as a workaround.

@danielrbradley danielrbradley transferred this issue from pulumi/pulumi-aws-native Dec 6, 2022
@danielrbradley danielrbradley added language/go area/codegen SDK-gen, program-gen, convert labels Dec 6, 2022
@justinvp justinvp removed the needs-triage Needs attention from the triage team label Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/codegen SDK-gen, program-gen, convert kind/bug Some behavior is incorrect or out of spec language/go
Projects
None yet
Development

No branches or pull requests

3 participants