class Secret
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.Batch.Secret |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsbatch#Secret |
![]() | software.amazon.awscdk.services.batch.Secret |
![]() | aws_cdk.aws_batch.Secret |
![]() | aws-cdk-lib » aws_batch » Secret |
A secret environment variable.
Example
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
new Secret()
Properties
Name | Type | Description |
---|---|---|
arn | string | The ARN of the secret. |
has | boolean | Whether this secret uses a specific JSON field. |
arn
Type:
string
The ARN of the secret.
hasField?
Type:
boolean
(optional)
Whether this secret uses a specific JSON field.
Methods
Name | Description |
---|---|
grant | Grants reading the secret to a principal. |
static from | Creates a environment variable value from a secret stored in AWS Secrets Manager. |
static from | Creates a environment variable value from a secret stored in AWS Secrets Manager. |
static from | Creates an environment variable value from a parameter stored in AWS Systems Manager Parameter Store. |
grantRead(grantee)
public grantRead(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grants reading the secret to a principal.
static fromSecretsManager(secret, field?)
public static fromSecretsManager(secret: ISecret, field?: string): Secret
Parameters
- secret
ISecret
— the secret stored in AWS Secrets Manager. - field
string
— the name of the field with the value that you want to set as the environment variable value.
Returns
Creates a environment variable value from a secret stored in AWS Secrets Manager.
static fromSecretsManagerVersion(secret, versionInfo, field?)
public static fromSecretsManagerVersion(secret: ISecret, versionInfo: SecretVersionInfo, field?: string): Secret
Parameters
- secret
ISecret
— the secret stored in AWS Secrets Manager. - versionInfo
Secret
— the version information to reference the secret.Version Info - field
string
— the name of the field with the value that you want to set as the environment variable value.
Returns
Creates a environment variable value from a secret stored in AWS Secrets Manager.
static fromSsmParameter(parameter)
public static fromSsmParameter(parameter: IParameter): Secret
Parameters
- parameter
IParameter
Returns
Creates an environment variable value from a parameter stored in AWS Systems Manager Parameter Store.