Issue while importing secret value in aws-cdk

Viewed 660

In AWS-CDK,

In stack-A, I exported a secret value using below code

        core.CfnOutput(
            self,
            "db-secret",
            value=secret_arn,
            export_name= "db-secret",
        )

above code successfully exported secret arn

In stack-B, i want to import the secret-arn and want to extract the secret value

I am using below code to achieve the task

        secret = sm.Secret.from_secret_attributes(self, "ImportedSecret",
          secret_complete_arn=db_secret
        )

when i am try to use this secret as a environmental variable in the fargate task_definition, i am encountering below error.

    raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: Expected a string, got {"$jsii.byref":"@aws-cdk/core.SecretValue@10330"}

Can anyone tell me how to import the value of the secret

0 Answers
Related