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

Nested blocks are broken with terraform-provider-aws v2.7.0 #9

Closed
minamijoyo opened this issue Apr 28, 2019 · 2 comments · Fixed by #16
Closed

Nested blocks are broken with terraform-provider-aws v2.7.0 #9

minamijoyo opened this issue Apr 28, 2019 · 2 comments · Fixed by #16

Comments

@minamijoyo
Copy link
Owner

This may be caused by a change for Terraform v0.12 support in the provider.

$ terraform version
Terraform v0.11.13
+ provider.aws v2.7.0

$ tfschema --version
0.2.0
$ tfschema resource show aws_security_group
+------------------------+-----------------------------------------------+----------+----------+----------+-----------+
| ATTRIBUTE              | TYPE                                          | REQUIRED | OPTIONAL | COMPUTED | SENSITIVE |
+------------------------+-----------------------------------------------+----------+----------+----------+-----------+
| arn                    | String                                        | false    | false    | true     | false     |
| description            | String                                        | false    | true     | false    | false     |
| egress                 | Set(Object(map[string]Type{"self":Bool,       | false    | true     | true     | false     |
|                        | "description":String,                         |          |          |          |           |
|                        | "from_port":Number,                           |          |          |          |           |
|                        | "prefix_list_ids":List(String),               |          |          |          |           |
|                        | "protocol":String,                            |          |          |          |           |
|                        | "cidr_blocks":List(String),                   |          |          |          |           |
|                        | "to_port":Number,                             |          |          |          |           |
|                        | "ipv6_cidr_blocks":List(String),              |          |          |          |           |
|                        | "security_groups":Set(String)}))              |          |          |          |           |
| id                     | String                                        | false    | true     | true     | false     |
| ingress                | Set(Object(map[string]Type{"protocol":String, | false    | true     | true     | false     |
|                        | "self":Bool, "prefix_list_ids":List(String),  |          |          |          |           |
|                        | "from_port":Number, "to_port":Number,         |          |          |          |           |
|                        | "security_groups":Set(String),                |          |          |          |           |
|                        | "cidr_blocks":List(String),                   |          |          |          |           |
|                        | "description":String,                         |          |          |          |           |
|                        | "ipv6_cidr_blocks":List(String)}))            |          |          |          |           |
| name                   | String                                        | false    | true     | true     | false     |
| name_prefix            | String                                        | false    | true     | false    | false     |
| owner_id               | String                                        | false    | false    | true     | false     |
| revoke_rules_on_delete | Bool                                          | false    | true     | false    | false     |
| tags                   | Map(String)                                   | false    | true     | false    | false     |
| vpc_id                 | String                                        | false    | true     | true     | false     |
+------------------------+-----------------------------------------------+----------+----------+----------+-----------+

block_type: timeouts, nesting: NestingSingle, min_items: 0, max_items: 0
+-----------+--------+----------+----------+----------+-----------+
| ATTRIBUTE | TYPE   | REQUIRED | OPTIONAL | COMPUTED | SENSITIVE |
+-----------+--------+----------+----------+----------+-----------+
| create    | String | false    | true     | false    | false     |
| delete    | String | false    | true     | false    | false     |
+-----------+--------+----------+----------+----------+-----------+
@minamijoyo
Copy link
Owner Author

It may be related to hashicorp/terraform-provider-aws#8187

minamijoyo added a commit that referenced this issue May 21, 2019
Fixes #9

Terraform v0.12 introduced a new `SchemaConfigModeAttr` feature.
Most attributes have simple types, but if `SchemaConfigModeAttr` is set for
an attribute, it is syntactically NestedBlock but semantically interpreted
as an Attribute. In this case, Attribute has a complex data type. It is
reasonable to use the same notation as the type annotation in HCL2 to
represent the correct data type. However, it seems that HCL2 has a type
annotation parser but no writer, so we implement it by ourselves.

See also:
- #9
- hashicorp/terraform-provider-aws#8187
- hashicorp/terraform#20626
- https://www.terraform.io/docs/configuration/types.html

This is a breaking change caused by the upstream,
so I think it is impossible to maintain tfschema backward compatibility.
I tried to be as consistent as possible.
@minamijoyo
Copy link
Owner Author

I confirmed that this is caused by a breaking change of Terraform v0.12.
Terraform v0.12 introduced a new SchemaConfigModeAttr feature.
hashicorp/terraform#20626

If SchemaConfigModeAttr is set for an attribute, it is syntactically NestedBlock but semantically interpreted as an Attribute.
There is no way to get the Attribute as original NestedBlock from configschema.

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

Successfully merging a pull request may close this issue.

1 participant