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

Importing a subnet gives a warning #2318

Closed
jkodroff opened this issue Jan 13, 2023 · 9 comments
Closed

Importing a subnet gives a warning #2318

jkodroff opened this issue Jan 13, 2023 · 9 comments
Assignees
Labels
area/import An issue related to `pulumi import` or the import resource option. impact/usability Something that impacts users' ability to use the product easily and intuitively kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Milestone

Comments

@jkodroff
Copy link
Member

What happened?

When importing an aws.ec2.Subnet, I get the following warning:

  aws:ec2:Subnet (import-subnet-edfe0bb0):
    warning: One or more imported inputs failed to validate. This is almost certainly a bug in the `aws` provider. The import will still proceed, but you will need to edit the generated code after copying it into your program.
    warning: aws:ec2/subnet:Subnet resource 'import-subnet-edfe0bb0' has a problem: Conflicting configuration arguments: "availability_zone": conflicts with availability_zone_id. Examine values at 'Subnet.AvailabilityZone'.
    warning: aws:ec2/subnet:Subnet resource 'import-subnet-edfe0bb0' has a problem: Conflicting configuration arguments: "availability_zone_id": conflicts with availability_zone. Examine values at 'Subnet.AvailabilityZoneId'.

Steps to reproduce

Run pulumi import on a subnet. Any subnet.

Expected Behavior

No warning. I would suggest we favor the AZ over the AZID since the former is more frequently specified as an input.

Actual Behavior

Warning.

Output of pulumi about

No response

Additional context

No response

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).

@jkodroff jkodroff added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Jan 13, 2023
@danielrbradley danielrbradley added impact/usability Something that impacts users' ability to use the product easily and intuitively area/import An issue related to `pulumi import` or the import resource option. and removed needs-triage Needs attention from the triage team labels Jan 17, 2023
@t0yv0
Copy link
Member

t0yv0 commented Apr 22, 2024

import * as aws from "@pulumi/aws";

const mainVpc = new aws.ec2.Vpc("main", {cidrBlock: "10.0.0.0/16"});

const example  = new aws.ec2.Subnet("in_secondary_cidr", {
    vpcId: mainVpc.id,
    cidrBlock: "10.0.0.0/24",
});


export const exampleId = example.id;

Now:

PULUMI_DEBUG_GRPC=/Users/t0yv0/bugs/aws-2318/here.json pulumi import aws:ec2/subnet:Subnet mynewsubnet subnet-07d413fe9a1b88d98
    warning: One or more imported inputs failed to validate. This is almost certainly a bug in the `aws` provider. The import will still proceed, but you will need to edit the generated code after copying it into your program.
    warning: aws:ec2/subnet:Subnet resource 'mynewsubnet' has a problem: Conflicting configuration arguments: "availability_zone": conflicts with availability_zone_id. Examine values at 'mynewsubnet.availabilityZone'.
    warning: aws:ec2/subnet:Subnet resource 'mynewsubnet' has a problem: Conflicting configuration arguments: "availability_zone_id": conflicts with availability_zone. Examine values at 'mynewsubnet.availabilityZoneId'.

From the log:

{
  "method": "/pulumirpc.ResourceProvider/Read",
  "request": {
    "id": "subnet-07d413fe9a1b88d98",
    "urn": "urn:pulumi:dev::aws-2318::aws:ec2/subnet:Subnet::mynewsubnet",
    "properties": {}
  },
  "response": {
    "id": "subnet-07d413fe9a1b88d98",
    "properties": {
      "__meta": "{\"e2bfb730-ecaa-11e6-8f88-34363bc7c4c0\":{\"create\":600000000000,\"delete\":1200000000000},\"schema_version\":\"1\"}",
      "arn": "arn:aws:ec2:us-east-1:616138583583:subnet/subnet-07d413fe9a1b88d98",
      "assignIpv6AddressOnCreation": false,
      "availabilityZone": "us-east-1a",
      "availabilityZoneId": "use1-az4",
      "cidrBlock": "10.0.0.0/24",
      "customerOwnedIpv4Pool": "",
      "enableDns64": false,
      "enableLniAtDeviceIndex": 0,
      "enableResourceNameDnsARecordOnLaunch": false,
      "enableResourceNameDnsAaaaRecordOnLaunch": false,
      "id": "subnet-07d413fe9a1b88d98",
      "ipv6CidrBlock": "",
      "ipv6CidrBlockAssociationId": "",
      "ipv6Native": false,
      "mapCustomerOwnedIpOnLaunch": false,
      "mapPublicIpOnLaunch": false,
      "outpostArn": "",
      "ownerId": "616138583583",
      "privateDnsHostnameTypeOnLaunch": "ip-name",
      "tags": {},
      "tagsAll": {},
      "vpcId": "vpc-07975d3c7b3adfd06"
    },
    "inputs": {
      "__defaults": [],
      "availabilityZone": "us-east-1a",
      "availabilityZoneId": "use1-az4",
      "cidrBlock": "10.0.0.0/24",
      "privateDnsHostnameTypeOnLaunch": "ip-name",
      "vpcId": "vpc-07975d3c7b3adfd06"
    }
  },
  "metadata": {
    "kind": "resource",
    "mode": "client",
    "name": "aws"
  }
}
{
  "method": "/pulumirpc.ResourceProvider/Check",
  "request": {
    "urn": "urn:pulumi:dev::aws-2318::aws:ec2/subnet:Subnet::mynewsubnet",
    "olds": {
      "__defaults": [],
      "availabilityZone": "us-east-1a",
      "availabilityZoneId": "use1-az4",
      "cidrBlock": "10.0.0.0/24",
      "privateDnsHostnameTypeOnLaunch": "ip-name",
      "vpcId": "vpc-07975d3c7b3adfd06"
    },
    "news": {
      "__defaults": [],
      "availabilityZone": "us-east-1a",
      "availabilityZoneId": "use1-az4",
      "cidrBlock": "10.0.0.0/24",
      "privateDnsHostnameTypeOnLaunch": "ip-name",
      "vpcId": "vpc-07975d3c7b3adfd06"
    },
    "randomSeed": "0U7ad3kEB4Ww2Qo4Fta15D0zwhCDnViQarQ9c1RfnTc="
  },
  "response": {
    "inputs": {
      "__defaults": [
        "assignIpv6AddressOnCreation",
        "enableDns64",
        "enableResourceNameDnsARecordOnLaunch",
        "enableResourceNameDnsAaaaRecordOnLaunch",
        "ipv6Native",
        "mapPublicIpOnLaunch"
      ],
      "assignIpv6AddressOnCreation": false,
      "availabilityZone": "us-east-1a",
      "availabilityZoneId": "use1-az4",
      "cidrBlock": "10.0.0.0/24",
      "enableDns64": false,
      "enableResourceNameDnsARecordOnLaunch": false,
      "enableResourceNameDnsAaaaRecordOnLaunch": false,
      "ipv6Native": false,
      "mapPublicIpOnLaunch": false,
      "privateDnsHostnameTypeOnLaunch": "ip-name",
      "vpcId": "vpc-07975d3c7b3adfd06"
    },
    "failures": [
      {
        "reason": "Conflicting configuration arguments: \"availability_zone\": conflicts with availability_zone_id. Examine values at 'mynewsubnet.availabilityZone'."
      },
      {
        "reason": "Conflicting configuration arguments: \"availability_zone_id\": conflicts with availability_zone. Examine values at 'mynewsubnet.availabilityZoneId'."
      }
    ]
  },
  "metadata": {
    "kind": "resource",
    "mode": "client",
    "name": "aws"
  }
}

@t0yv0
Copy link
Member

t0yv0 commented Apr 22, 2024

@t0yv0
Copy link
Member

t0yv0 commented Apr 22, 2024

Both attributes seem to be Optional+Computed meaning that they can be set by either the provider or the user, and Pulumi maps them to inputs and outputs.

@t0yv0
Copy link
Member

t0yv0 commented Apr 22, 2024

Curious how this works in Terraform proper, checking.

@t0yv0
Copy link
Member

t0yv0 commented Apr 22, 2024

Looks like in TF there are no warnings on import but https://spacelift.io/blog/importing-exisiting-infrastructure-into-terraform is suggesting to manually edit the program at which point this issue can be manually resolved .

@t0yv0 t0yv0 self-assigned this Apr 26, 2024
t0yv0 added a commit to pulumi/pulumi-terraform-bridge that referenced this issue May 9, 2024
Toward #1225 -
this fixes the special case of ConflictsWith warnings. This fixes
spurious warnings on `pulumi import`, popular bugs such as:

- pulumi/pulumi-aws#2318 
- pulumi/pulumi-aws#3670
- pulumi/pulumi-gitlab#293
- pulumi/pulumi-gcp#844
- pulumi/pulumi-linode#373

TF does not guarantee Read results to be compatible with calling Check
on, in particular Read can return results that run afoul of
ConflictsWith constraint. This change compensates by arbitrarily
dropping data from the Read result until it passes ConflictsWith checks.

This affects `pulumi refresh` as well as I think it should although I
have not seen "in the wild" cases where refresh is affected, since it
typically will not copy these properties to the input bag unless they're
present in old inputs, which are usually correct wrt to ConflictsWith.
@flostadler
Copy link
Contributor

flostadler commented May 15, 2024

@t0yv0 I checked whether this was fixed by the bridge upgrade #3929 to 3.82.0, but it's still occurring on pulumi-aws version 6.36.0:

pulumi import aws:ec2/subnet:Subnet mynewsubnet subnet-0ce78cf155fa924d6
...
aws:ec2:Subnet (mynewsubnet):
    warning: One or more imported inputs failed to validate. This is almost certainly a bug in the `aws` provider. The import will still proceed, but you will need to edit the generated code after copying it into your program.
    warning: aws:ec2/subnet:Subnet resource 'mynewsubnet' has a problem: Conflicting configuration arguments: "availability_zone_id": conflicts with availability_zone. Examine values at 'mynewsubnet.availabilityZoneId'.
    warning: aws:ec2/subnet:Subnet resource 'mynewsubnet' has a problem: Conflicting configuration arguments: "availability_zone": conflicts with availability_zone_id. Examine values at 'mynewsubnet.availabilityZone'.

@t0yv0
Copy link
Member

t0yv0 commented May 16, 2024

Thanks so much for checking @flostadler

Unfortunately it appears there was a slight versioning error so that the bridge fix is not made available yet for AWS. This issue should resolve itself on the next bridge release and automated round of upgrades.

There is still a bug on this version:

  @pulumi/aws     6.36.0

This version uses:

  github.com/pulumi/pulumi-terraform-bridge/pf v0.35.0
  github.com/pulumi/pulumi-terraform-bridge/v3 v3.82.0

Unfortunately the fix did not make it to the said bridge version:

  #+begin_src shell :results output verbatim
    cd ~/code/pulumi-terraform-bridge
    git log v3.82.0..6814027a7241fbd765b510ca4d386f9679f7cb9c
  #+end_src

  #+RESULTS:
  #+begin_example
  commit 6814027a7241fbd765b510ca4d386f9679f7cb9c
  Author: Anton Tayanovskyy <anton@pulumi.com>
  Date:   Thu May 9 17:39:13 2024 -0400

      Remove spurious ConflictsWith warnings on import (#1948)

      Toward https://github.com/pulumi/pulumi-terraform-bridge/issues/1225 -
      this fixes the special case of ConflictsWith warnings. This fixes
      spurious warnings on `pulumi import`, popular bugs such as:

      - https://github.com/pulumi/pulumi-aws/issues/2318
      - https://github.com/pulumi/pulumi-aws/issues/3670
      - https://github.com/pulumi/pulumi-gitlab/issues/293
      - https://github.com/pulumi/pulumi-gcp/issues/844
      - https://github.com/pulumi/pulumi-linode/issues/373

      TF does not guarantee Read results to be compatible with calling Check
      on, in particular Read can return results that run afoul of
      ConflictsWith constraint. This change compensates by arbitrarily
      dropping data from the Read result until it passes ConflictsWith checks.

      This affects `pulumi refresh` as well as I think it should although I
      have not seen "in the wild" cases where refresh is affected, since it
      typically will not copy these properties to the input bag unless they're
      present in old inputs, which are usually correct wrt to ConflictsWith.
  #+end_example

@t0yv0
Copy link
Member

t0yv0 commented May 24, 2024

This should be fixed by #3984 pulling in https://github.com/pulumi/pulumi-terraform-bridge/releases/tag/v3.83.0

I will cut a new release.

@t0yv0
Copy link
Member

t0yv0 commented May 24, 2024

This issue is fixed in v6.37.1. Example:

Importing (dev)

View in Browser (Ctrl+O): https://app.pulumi.com/anton-pulumi-corp/aws-2318/dev/updates/36

     Type                 Name          Status               
 +   pulumi:pulumi:Stack  aws-2318-dev  created (2s)         
 =   └─ aws:ec2:Subnet    mynewsubnet   imported (0.42s)     

Resources:
    + 1 created
    = 1 imported
    2 changes

Duration: 3s

Please copy the following code into your Pulumi application. Not doing so
will cause Pulumi to report that an update will happen on the next update command.

Please note that the imported resources are marked as protected. To destroy them
you will need to remove the `protect` option and run `pulumi update` *before*
the destroy will take effect.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const mynewsubnet = new aws.ec2.Subnet("mynewsubnet", {
    availabilityZone: "us-east-1d",
    cidrBlock: "10.0.0.0/24",
    privateDnsHostnameTypeOnLaunch: "ip-name",
    vpcId: "vpc-088588305ca732419",
}, {
    protect: true,
});

The provider is picking availabilityZone and dropping availabilityZoneId from the read result to avoid the warning.

@t0yv0 t0yv0 added the resolution/fixed This issue was fixed label May 24, 2024
@t0yv0 t0yv0 closed this as completed May 24, 2024
@t0yv0 t0yv0 added this to the 0.105 milestone May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/import An issue related to `pulumi import` or the import resource option. impact/usability Something that impacts users' ability to use the product easily and intuitively kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

No branches or pull requests

4 participants