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

Import error: kops cluster with external policies #282

Closed
rmgpinto opened this issue Jul 12, 2021 · 12 comments
Closed

Import error: kops cluster with external policies #282

rmgpinto opened this issue Jul 12, 2021 · 12 comments

Comments

@rmgpinto
Copy link
Contributor

rmgpinto commented Jul 12, 2021

I'm trying to import an existing cluster with external_policies defined, but I get:

provider.terraform-provider-kops_v1.20.0-beta.2: 2021/07/12 21:57:24 [ERR] Error writing fields: external_policies.node.1: '': source data must be an array or slice, got string: timestamp=2021-07-12T21:57:24.554+0100

I have something similar to this:

spec:
  externalPolicies:
    node:
    - arn:aws:iam::123456789000:policy/test-policy-1
    - arn:aws:iam::123456789000:policy/test-policy-2
@rmgpinto rmgpinto changed the title Import error Import error: kops cluster with external policies Jul 12, 2021
@eddycharly
Copy link
Owner

What version are you using ?

I will test it tomorrow, expansion and flattening code looks correct but i fear that terraform only supports maps of primitive types https://github.com/hashicorp/terraform-plugin-sdk/blob/5f0e47111e779cb308990590c18d0ed547f0dd37/helper/schema/schema.go#L143-L151

If it's really the case i will find a workaround.

@rmgpinto
Copy link
Contributor Author

Thanks for the quick reply. Latest version: terraform-provider-kops_v1.20.0-beta.2

@eddycharly
Copy link
Owner

It looks like there is an open issue from 2016 hashicorp/terraform-plugin-sdk#62

I will look into it tomorrow… maybe changing the map by a list with a key attribute 🤔

Fortunately the number of affected properties is pretty low.

@eddycharly
Copy link
Owner

external_policy {
  key = node
  value = [ arn1, arn2, etc. ]
}

@rmgpinto
Copy link
Contributor Author

Hi @eddycharly, any news on this? Thanks

@eddycharly
Copy link
Owner

Hey @rmgpinto I confirmed the issue and added an option in the provider to setup a cloud api mock so that i can write integration tests for such cases.

Now i'm going to start fixing it 🤞

@eddycharly
Copy link
Owner

eddycharly commented Jul 14, 2021

It looks like #287 is fixing it.

At least, it doesn't complain when parsing tf code containing:

  external_policies {
    key = "node"
    value = [
      "arn:aws:iam::123456789000:policy/test-policy-1",
      "arn:aws:iam::123456789000:policy/test-policy-2"
    ]
  }

@rmgpinto
Copy link
Contributor Author

Great, I'll test once it's released.

@eddycharly
Copy link
Owner

Would it be ok to test it with a 1.21 alpha release ?

@rmgpinto
Copy link
Contributor Author

rmgpinto commented Jul 15, 2021 via email

@eddycharly
Copy link
Owner

Perfect, v1.21.0-alpha.3 is being built, it should be available in a couple of minutes.

@rmgpinto
Copy link
Contributor Author

LGTM, thanks

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