You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exporttypeEcsServiceProps={environment: {[key: string]: string}secrets: {[key: string]: Secret}}exportclassECSServiceextendsConstruct{constructor(scope: Construct,id: string)){super(scope,id);consttaskDefinition=newFargateTaskDefinition(this,"TaskDefinition",{});constcontainer=taskDefinition.addContainer("Container",{image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),environment: props.environment,secrets: props.secrets})// service definition will be here...}}
Question
I want to use auth.userPoolClientSecret in ECS, but I don't know how to do it.
exportclassAppStackextendsStack{constructor(scope: Construct,id: string{super(scope,id,props);constauth=newAuth(this,"Auth")constecsService=newECSService(this,"service",{environment: {"COGNITO_SECRET": auth.userPoolClientSecret.toString()// This is dangerous},secrets: {// can I store `auth.userPoolClientSecret` in SecretManager or SSM ParameterStore and // use it at here?}})}}
Calling toString() like above will cause an error like below, and I know this is a dangerous usage.
Resolution error: Synthing a secret value to Resources/... Using a SecretValue here risks exposing your secret. Only pass SecretValues to constructs that accept a SecretValue property, or call AWS Secrets Manager directly in your runtime code. Call 'secretValue.unsafeUnwrap()' if you understand and accept the risks.
For now I came up with the idea like this, but it is a bit confusing.
Deploy Cognito as a separate stack
Store the secret in the SSM ParameterStore manually
Use it as secrets of ECSService
So what is the recommended way to use SecretValue in ECS?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello. This is my first time using CDK, so sorry if this is a weird question.
Situation
For example, I have two constructs like this:
Question
I want to use
auth.userPoolClientSecret
in ECS, but I don't know how to do it.Calling
toString()
like above will cause an error like below, and I know this is a dangerous usage.For now I came up with the idea like this, but it is a bit confusing.
secrets
ofECSService
So what is the recommended way to use SecretValue in ECS?
Beta Was this translation helpful? Give feedback.
All reactions