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 Computed Attributes for Block Types #29

Closed
skorfmann opened this issue Apr 27, 2020 · 4 comments
Closed

Nested Computed Attributes for Block Types #29

skorfmann opened this issue Apr 27, 2020 · 4 comments
Labels
bug Something isn't working waiting-for-3rd-party-fix

Comments

@skorfmann
Copy link
Contributor

The resource Kinesis Analytics Application has nested computed attributes for block types which aren't listed on the documentation. I think it makes sense to ignore those attributes. Thoughts?

      "inputs": {
        "nesting_mode": "list",
        "block": {
          "attributes": {
            "id": {
              "type": "string",
              "computed": true
            },
            "name_prefix": {
              "type": "string",
              "required": true
            },
            "starting_position_configuration": {
              "type": [
                "list",
                [
                  "object",
                  {
                    "starting_position": "string"
                  }
                ]
              ],
              "computed": true
            },
            "stream_names": {
              "type": [
                "set",
                "string"
              ],
              "computed": true
            }
          }

The Go Schema defines it as expected:

						"starting_position_configuration": {
							Type:     schema.TypeList,
							Computed: true,
							Elem: &schema.Resource{
								Schema: map[string]*schema.Schema{
									"starting_position": {
										Type:     schema.TypeString,
										Computed: true,
									},
								},
							},
						},
						"stream_names": {
							Type:     schema.TypeSet,
							Computed: true,
							Elem:     &schema.Schema{Type: schema.TypeString},
						},
skorfmann added a commit that referenced this issue Apr 30, 2020
This provides a fix for #12 and includes some refactoring around the resource parsing / emitting.

The primary goal of the refactoring was, to split the parsing from the emitting to make it easier to understand. I'm still not quite happy with the result (in particular around the models, and that some logic is spread across multiple places). I think it needs another iteration, but for alpha it should do.

Right now it's in the "it's working" state, and "jsii" will compile the "AWS" provider without an error. I haven't done a full sanity check of the generated resources, but for the most part it should be usable.

In regards to the complex computed types, I'd see it as a first stab at the problem. It's not flexible and serves a very specific use case only. The goal:

- Make complex computed types accessible
- Provide type information for the computed properties of those types
- Keep it within the constraints of jsii, namely no generics and no proxies (see #12)

A few issues were created as a follow up - see #24 #25 #26 #27 #28 #29 #39
anubhavmishra pushed a commit that referenced this issue May 5, 2020
This provides a fix for #12 and includes some refactoring around the resource parsing / emitting.

The primary goal of the refactoring was, to split the parsing from the emitting to make it easier to understand. I'm still not quite happy with the result (in particular around the models, and that some logic is spread across multiple places). I think it needs another iteration, but for alpha it should do.

Right now it's in the "it's working" state, and "jsii" will compile the "AWS" provider without an error. I haven't done a full sanity check of the generated resources, but for the most part it should be usable.

In regards to the complex computed types, I'd see it as a first stab at the problem. It's not flexible and serves a very specific use case only. The goal:

- Make complex computed types accessible
- Provide type information for the computed properties of those types
- Keep it within the constraints of jsii, namely no generics and no proxies (see #12)

A few issues were created as a follow up - see #24 #25 #26 #27 #28 #29 #39
@joatmon08 joatmon08 added the bug Something isn't working label May 11, 2020
@skorfmann
Copy link
Contributor Author

That's what would be generated from the schema.

export class KinesisAnalyticsApplicationInputsStartingPositionConfiguration extends ComplexComputedList {

  // starting_position - computed: true, optional: false, required: true
  public get startingPosition() {
    return this.getStringAttribute('starting_position');
  }
}

export interface KinesisAnalyticsApplicationInputs {
  // ...
  readonly startingPositionConfiguration: KinesisAnalyticsApplicationInputsStartingPositionConfiguration;
  // ...
}

At the moment, these anonymous interfaces are only usable to provide data. Therefore it doesn't make sense to provide accessors deeply nested in there. In this case, it would even be invalid since the Terraform provider wouldn't be able to handle these attributes.

@skorfmann
Copy link
Contributor Author

This seems to be somewhat related hashicorp/terraform-provider-aws#7551

@github-actions
Copy link
Contributor

I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working waiting-for-3rd-party-fix
Projects
None yet
Development

No branches or pull requests

3 participants