Secret Class
A secret environment variable.
Example
ts
declare const mySecret: secretsmanager.ISecret;
const jobDefn = new batch.EcsJobDefinition(this, 'JobDefn', {
container: new batch.EcsEc2ContainerDefinition(this, 'containerDefn', {
image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
memory: cdk.Size.mebibytes(2048),
cpu: 256,
secrets: {
MY_SECRET_ENV_VAR: batch.Secret.fromSecretsManager(mySecret),
}
}),
});
Initializer
ts
new Secret()
python
Secret()
java
new Secret()
csharp
new Secret()
go
NewSecret()
Properties
Methods
fromSecretsManager(secret: ISecret, field?: string): Secret // chainable@staticmethod def from_secrets_manager(secret: ISecret, field: typing.Optional[str] = None) -> Secretpublic static Secret fromSecretsManager(ISecret secret, String field)public static Secret FromSecretsManager(ISecret secret, string? field = null)func FromSecretsManager(Secret ISecret, Field *string) Secretstatic#Creates a environment variable value from a secret stored in AWS Secrets Manager.
2 parameters
Parameters
secretsecretsecretsecretSecret— the secret stored in AWS Secrets Manager.fieldfieldfieldfieldField— the name of the field with the value that you want to set as the environment variable value.
fromSecretsManagerVersion(secret: ISecret, versionInfo: SecretVersionInfo, field?: string): Secret // chainable@staticmethod def from_secrets_manager_version(secret: ISecret, version_info: SecretVersionInfo, field: typing.Optional[str] = None) -> Secretpublic static Secret fromSecretsManagerVersion(ISecret secret, SecretVersionInfo versionInfo, String field)public static Secret FromSecretsManagerVersion(ISecret secret, SecretVersionInfo versionInfo, string? field = null)func FromSecretsManagerVersion(Secret ISecret, VersionInfo SecretVersionInfo, Field *string) Secretstatic#Creates a environment variable value from a secret stored in AWS Secrets Manager.
3 parameters
Parameters
secretsecretsecretsecretSecret— the secret stored in AWS Secrets Manager.versionInfoversion_infoversionInfoversionInfoVersionInfo— the version information to reference the secret.fieldfieldfieldfieldField— the name of the field with the value that you want to set as the environment variable value.
fromSsmParameter(parameter: IParameter): Secret // chainable@staticmethod def from_ssm_parameter(parameter: IParameter) -> Secretpublic static Secret fromSsmParameter(IParameter parameter)public static Secret FromSsmParameter(IParameter parameter)func FromSsmParameter(Parameter IParameter) Secretstatic#Creates an environment variable value from a parameter stored in AWS Systems Manager Parameter Store.
grantRead(grantee: IGrantable): Grantdef grant_read(self, grantee: IGrantable) -> Grantpublic Grant grantRead(IGrantable grantee)public Grant GrantRead(IGrantable grantee)func GrantRead(Grantee IGrantable) Grant#Grants reading the secret to a principal [disable-awslint:no-grants].