Home > Mobile >  How can i get parameters from Construct before finishing of creation stack
How can i get parameters from Construct before finishing of creation stack

Time:07-18

Can you help me please? I create DatabaseInstanceEngine and eks secret and want to put db_instance_endpoint_address to this secret

self.cluster.add_manifest('my-secret-env', {
      "kind": "Secret",
      "apiVersion": "v1",
      "metadata": {
        "name": "my-secret-env",
        'namespace': 'default'
      },
      "data": {
        "DATA_HOST": self._base64encode(self.db.db_instance_endpoint_address),
        
      }
    })

after execution I see ${Token[TOKEN.475]} instead of value When i create SSM parameter (only for test)

ssm_parameter = ssm.StringParameter(self, "mySsmParameter",
                      parameter_name="mySsmParameter",
                      string_value=self.db.db_instance_endpoint_address,
                      type=ssm.ParameterType.STRING
                      )

I see correct value How can i resolve this token? secretenv.node.add_dependency(self.db) did not help Thank you

CodePudding user response:

Try without self._base64encode(.....)

explain: when you reference some value in CDK it puts a reference string in the cloudformation template and resolves the value at deploy time, when you encode this value as base64 it doesn't resolve at deploy time.

Take a look a the cloudformation template after you run synth.

CodePudding user response:

Solved. I changed python's base64 to Fn.base64 and problem was solved because resolve Fn.base64 tokens. Unfortunately this way is not good for DatabaseInstance .secret.secret_value_from_json('password').unsafe_unwrap()

I recieve this using Customresource

  • Related