@Generated(value="jsii-pacmak/1.70.0 (build 03c2f6f)", date="2022-11-01T13:16:47.629Z") @Stability(value=Experimental) public abstract class Secret extends software.amazon.jsii.JsiiObject
Example:
Secret secret;
Secret dbSecret;
StringParameter parameter;
TaskDefinition taskDefinition;
Bucket s3Bucket;
ContainerDefinition newContainer = taskDefinition.addContainer("container", ContainerDefinitionOptions.builder()
.image(ContainerImage.fromRegistry("amazon/amazon-ecs-sample"))
.memoryLimitMiB(1024)
.environment(Map.of( // clear text, not for sensitive data
"STAGE", "prod"))
.environmentFiles(List.of(EnvironmentFile.fromAsset("./demo-env-file.env"), EnvironmentFile.fromBucket(s3Bucket, "assets/demo-env-file.env")))
.secrets(Map.of( // Retrieved from AWS Secrets Manager or AWS Systems Manager Parameter Store at container start-up.
"SECRET", Secret.fromSecretsManager(secret),
"DB_PASSWORD", Secret.fromSecretsManager(dbSecret, "password"), // Reference a specific JSON field, (requires platform version 1.4.0 or later for Fargate tasks)
"API_KEY", Secret.fromSecretsManagerVersion(secret, SecretVersionInfo.builder().versionId("12345").build(), "apiKey"), // Reference a specific version of the secret by its version id or version stage (requires platform version 1.4.0 or later for Fargate tasks)
"PARAMETER", Secret.fromSsmParameter(parameter)))
.build());
newContainer.addEnvironment("QUEUE_NAME", "MyQueue");
| Modifier | Constructor and Description |
|---|---|
protected |
Secret() |
protected |
Secret(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
Secret(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
static Secret |
fromSecretsManager(ISecret secret)
(experimental) Creates a environment variable value from a secret stored in AWS Secrets Manager.
|
static Secret |
fromSecretsManager(ISecret secret,
String field)
(experimental) Creates a environment variable value from a secret stored in AWS Secrets Manager.
|
static Secret |
fromSecretsManagerVersion(ISecret secret,
SecretVersionInfo versionInfo)
(experimental) Creates a environment variable value from a secret stored in AWS Secrets Manager.
|
static Secret |
fromSecretsManagerVersion(ISecret secret,
SecretVersionInfo versionInfo,
String field)
(experimental) Creates a environment variable value from a secret stored in AWS Secrets Manager.
|
static Secret |
fromSsmParameter(IParameter parameter)
(experimental) Creates an environment variable value from a parameter stored in AWS Systems Manager Parameter Store.
|
abstract String |
getArn()
(experimental) The ARN of the secret.
|
abstract Boolean |
getHasField()
(experimental) Whether this secret uses a specific JSON field.
|
abstract Grant |
grantRead(IGrantable grantee)
(experimental) Grants reading the secret to a principal.
|
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetprotected Secret(software.amazon.jsii.JsiiObjectRef objRef)
protected Secret(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Experimental) protected Secret()
@Stability(value=Experimental) @NotNull public static Secret fromSecretsManager(@NotNull ISecret secret, @Nullable String field)
secret - the secret stored in AWS Secrets Manager. This parameter is required.field - the name of the field with the value that you want to set as the environment variable value.@Stability(value=Experimental) @NotNull public static Secret fromSecretsManager(@NotNull ISecret secret)
secret - the secret stored in AWS Secrets Manager. This parameter is required.@Stability(value=Experimental) @NotNull public static Secret fromSecretsManagerVersion(@NotNull ISecret secret, @NotNull SecretVersionInfo versionInfo, @Nullable String field)
secret - the secret stored in AWS Secrets Manager. This parameter is required.versionInfo - the version information to reference the secret. This parameter is required.field - the name of the field with the value that you want to set as the environment variable value.@Stability(value=Experimental) @NotNull public static Secret fromSecretsManagerVersion(@NotNull ISecret secret, @NotNull SecretVersionInfo versionInfo)
secret - the secret stored in AWS Secrets Manager. This parameter is required.versionInfo - the version information to reference the secret. This parameter is required.@Stability(value=Experimental) @NotNull public static Secret fromSsmParameter(@NotNull IParameter parameter)
parameter - This parameter is required.@Stability(value=Experimental) @NotNull public abstract Grant grantRead(@NotNull IGrantable grantee)
grantee - This parameter is required.@Stability(value=Experimental) @NotNull public abstract String getArn()
@Stability(value=Experimental) @Nullable public abstract Boolean getHasField()
Copyright © 2022. All rights reserved.