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

Computed Lists and Maps #42

Closed
skorfmann opened this issue May 2, 2020 · 5 comments
Closed

Computed Lists and Maps #42

skorfmann opened this issue May 2, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@skorfmann
Copy link
Contributor

With the current implementation of computed Lists and Maps we can access single elements (see #31 / #12). What we can't do right now:

  • Iterate programatically
  • Pass a computed List / Map as input to another Resource / Module
@LumaKernel
Copy link

Maybe related: #796

We can't use the technique described in above PR

const awsRoute53RecordExample = new aws.Route53Record(this, "example", {
  allowOverwrite: true,
  name: "${each.value.name}",
  records: ["${each.value.record}"],
  ttl: 60,
  type: "${each.value.type}",
  zoneId: dataAwsRoute53Zone.example.zoneId,
});
awsRoute53RecordAwsRoute53RecordExample.addOverride(
  "for_each",
  `\${{
    for dvo in ${awsAcmCertificateExample.domainValidationOptions} : dvo.domain_name => {
      name   = dvo.resource_record_name
      record = dvo.resource_record_value
      type   = dvo.resource_record_type
    }
  }}`
);

bacause domainValidationOptions is now function. (Finding workaround 😢)
And we don't have any way to know the keys of domainValidationOptions.

To achieve getting the proper interface, we should take care about unawareness of number of items by cdk side (cdk is just a static HCL generator).

That's why we can't use array/map/object for this. Thus I want to suggest iterable like signature.
Writing following to produce the HCL code that we wanted.

awsAcmCertificateExample.domainValidationOptions.entries().map((([_key, value]) => {
  return [value.domainName, {name: value.resourceRecordName, /* ... */}];
})).fromEntries()

Maybe at least what we want are .entries, .map, .fromEntries, and we may have .filter, .flatMap, .concat, ....

In some cases, for example VPC illustrated in #994, we can know the number of items because they may be the identical number of input. We should consider whether to specialize this case, but I think it is not necessary. I think .map is enough for most cases.

Making it dynamic is charming, but it looks hard. I think iterator like interface is good compromise for now.

I believe it's possible solution. If you like this and nobody will implement, I want to tackle implementing this next months.

@LumaKernel
Copy link

We can consider special mapper like .mapResource for top-level (non expression).

@jsteinich
Copy link
Collaborator

See also #1089 and #1130.

I want to tackle implementing this next months.

That's great. We can certainly work with you to come up with a workable design.
One of the challenges comes from needing to work within the constraints of jsii so that functionality will be available in other languages.

@DanielMSchmidt
Copy link
Contributor

@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
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants