aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.54k stars 3.86k forks source link

(opensearch): domain doesn't handle tokens in capacity configuration #15014

Closed leantorres73 closed 2 years ago

leantorres73 commented 3 years ago

If I set SSM for some parameters like dataNodeInstanceType, if fails on deployment time

Reproduction Steps

Create a ES Domain, and set capacity using SSM, like this:

capacity: {
      dataNodeInstanceType: `${ssm.StringParameter.valueForStringParameter(stack, 'ESInstanceTypeSSM', `elasticsearch/instance-type`)}.elasticsearch`,
      masterNodeInstanceType: `${ssm.StringParameter.valueForStringParameter(stack, 'ESInstanceTypeSSM', `elasticsearch/instance-type`)}.elasticsearch`,
      masterNodes: '1', 
      dataNodes: 2
}, 

Also, it shouldn't check if '.elasticsearch' is part of the text if a token is set there, but this second one is minor bug, the other one is an impediment of using SSM with ES configurations

What did you expect to happen?

Token resolved correctly.

What actually happened?

It fails, internally it's doing a .toLowerCase() and it's breaking the token

"${token[token.718]}.elasticsearch" instead of "${Token[Token.718]}.elasticsearch"

Environment


This is :bug: Bug Report

skinny85 commented 3 years ago

We need to add a Token.isUnresolved() check here (and probably a few similar places in that class as well).

BenChaimberg commented 3 years ago

smaller reproducible example without SSM:

new Domain(scope, 'Domain', {
  version: ElasticsearchVersion.V6_5,
  capacity: {
    dataNodeInstanceType: `${Fn.ref('SomeLogicalId')}.elasticsearch`,
  },
});

...produces ${token[token.59]}.elasticsearch under ElasticsearchClusterConfig.InstanceType

leantorres73 commented 2 years ago

Any updates on this?

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.