Class Secret

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.ecs.Secret
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.103.1 (build bef2dea)", date="2024-10-25T14:21:14.673Z") @Stability(Stable) public abstract class Secret extends software.amazon.jsii.JsiiObject
A secret environment variable.

Example:

 Secret secret;
 StringParameter parameter;
 Ec2TaskDefinition taskDefinition = new Ec2TaskDefinition(this, "TaskDef");
 taskDefinition.addContainer("TheContainer", ContainerDefinitionOptions.builder()
         .image(ContainerImage.fromRegistry("example-image"))
         .memoryLimitMiB(256)
         .logging(LogDrivers.firelens(FireLensLogDriverProps.builder()
                 .options(Map.of())
                 .secretOptions(Map.of( // Retrieved from AWS Secrets Manager or AWS Systems Manager Parameter Store
                         "apikey", Secret.fromSecretsManager(secret),
                         "host", Secret.fromSsmParameter(parameter)))
                 .build()))
         .build());
 
  • Nested Class Summary

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
    protected
    Secret(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    Secret(software.amazon.jsii.JsiiObjectRef objRef)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Secret
    Creates a environment variable value from a secret stored in AWS Secrets Manager.
    static Secret
    Creates a environment variable value from a secret stored in AWS Secrets Manager.
    static Secret
    Creates a environment variable value from a secret stored in AWS Secrets Manager.
    static Secret
    Creates a environment variable value from a secret stored in AWS Secrets Manager.
    static Secret
    Creates an environment variable value from a parameter stored in AWS Systems Manager Parameter Store.
    abstract String
    The ARN of the secret.
    abstract Boolean
    Whether this secret uses a specific JSON field.
    abstract Grant
    Grants reading the secret to a principal.

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • Constructor Details

    • Secret

      protected Secret(software.amazon.jsii.JsiiObjectRef objRef)
    • Secret

      protected Secret(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Secret

      @Stability(Stable) protected Secret()
  • Method Details

    • fromSecretsManager

      @Stability(Stable) @NotNull public static Secret fromSecretsManager(@NotNull ISecret secret, @Nullable String field)
      Creates a environment variable value from a secret stored in AWS Secrets Manager.

      Parameters:
      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.
    • fromSecretsManager

      @Stability(Stable) @NotNull public static Secret fromSecretsManager(@NotNull ISecret secret)
      Creates a environment variable value from a secret stored in AWS Secrets Manager.

      Parameters:
      secret - the secret stored in AWS Secrets Manager. This parameter is required.
    • fromSecretsManagerVersion

      @Stability(Stable) @NotNull public static Secret fromSecretsManagerVersion(@NotNull ISecret secret, @NotNull SecretVersionInfo versionInfo, @Nullable String field)
      Creates a environment variable value from a secret stored in AWS Secrets Manager.

      Parameters:
      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.
    • fromSecretsManagerVersion

      @Stability(Stable) @NotNull public static Secret fromSecretsManagerVersion(@NotNull ISecret secret, @NotNull SecretVersionInfo versionInfo)
      Creates a environment variable value from a secret stored in AWS Secrets Manager.

      Parameters:
      secret - the secret stored in AWS Secrets Manager. This parameter is required.
      versionInfo - the version information to reference the secret. This parameter is required.
    • fromSsmParameter

      @Stability(Stable) @NotNull public static Secret fromSsmParameter(@NotNull IParameter parameter)
      Creates an environment variable value from a parameter stored in AWS Systems Manager Parameter Store.

      Parameters:
      parameter - This parameter is required.
    • grantRead

      @Stability(Stable) @NotNull public abstract Grant grantRead(@NotNull IGrantable grantee)
      Grants reading the secret to a principal.

      Parameters:
      grantee - This parameter is required.
    • getArn

      @Stability(Stable) @NotNull public abstract String getArn()
      The ARN of the secret.
    • getHasField

      @Stability(Stable) @Nullable public abstract Boolean getHasField()
      Whether this secret uses a specific JSON field.