Class DockerCredential

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.pipelines.DockerCredential
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:49.820Z") @Stability(Stable) public abstract class DockerCredential extends software.amazon.jsii.JsiiObject
Represents credentials used to access a Docker registry.

Example:

 ISecret dockerHubSecret = Secret.fromSecretCompleteArn(this, "DHSecret", "arn:aws:...");
 ISecret customRegSecret = Secret.fromSecretCompleteArn(this, "CRSecret", "arn:aws:...");
 IRepository repo1 = Repository.fromRepositoryArn(this, "Repo", "arn:aws:ecr:eu-west-1:0123456789012:repository/Repo1");
 IRepository repo2 = Repository.fromRepositoryArn(this, "Repo", "arn:aws:ecr:eu-west-1:0123456789012:repository/Repo2");
 CodePipeline pipeline = CodePipeline.Builder.create(this, "Pipeline")
         .dockerCredentials(List.of(DockerCredential.dockerHub(dockerHubSecret), DockerCredential.customRegistry("dockerregistry.example.com", customRegSecret), DockerCredential.ecr(List.of(repo1, repo2))))
         .synth(ShellStep.Builder.create("Synth")
                 .input(CodePipelineSource.connection("my-org/my-app", "main", ConnectionSourceOptions.builder()
                         .connectionArn("arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41")
                         .build()))
                 .commands(List.of("npm ci", "npm run build", "npx cdk synth"))
                 .build())
         .build();
 
  • Constructor Details

    • DockerCredential

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

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

      @Stability(Stable) protected DockerCredential(@Nullable List<DockerCredentialUsage> usages)
      Parameters:
      usages -
    • DockerCredential

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

    • customRegistry

      @Stability(Stable) @NotNull public static DockerCredential customRegistry(@NotNull String registryDomain, @NotNull ISecret secret, @Nullable ExternalDockerCredentialOptions opts)
      Creates a DockerCredential for a registry, based on its domain name (e.g., 'www.example.com').

      Parameters:
      registryDomain - This parameter is required.
      secret - This parameter is required.
      opts -
    • customRegistry

      @Stability(Stable) @NotNull public static DockerCredential customRegistry(@NotNull String registryDomain, @NotNull ISecret secret)
      Creates a DockerCredential for a registry, based on its domain name (e.g., 'www.example.com').

      Parameters:
      registryDomain - This parameter is required.
      secret - This parameter is required.
    • dockerHub

      @Stability(Stable) @NotNull public static DockerCredential dockerHub(@NotNull ISecret secret, @Nullable ExternalDockerCredentialOptions opts)
      Creates a DockerCredential for DockerHub.

      Convenience method for customRegistry('https://index.docker.io/v1/', opts).

      Parameters:
      secret - This parameter is required.
      opts -
    • dockerHub

      @Stability(Stable) @NotNull public static DockerCredential dockerHub(@NotNull ISecret secret)
      Creates a DockerCredential for DockerHub.

      Convenience method for customRegistry('https://index.docker.io/v1/', opts).

      Parameters:
      secret - This parameter is required.
    • ecr

      @Stability(Stable) @NotNull public static DockerCredential ecr(@NotNull List<? extends IRepository> repositories, @Nullable EcrDockerCredentialOptions opts)
      Creates a DockerCredential for one or more ECR repositories.

      NOTE - All ECR repositories in the same account and region share a domain name (e.g., 0123456789012.dkr.ecr.eu-west-1.amazonaws.com), and can only have one associated set of credentials (and DockerCredential). Attempting to associate one set of credentials with one ECR repo and another with another ECR repo in the same account and region will result in failures when using these credentials in the pipeline.

      Parameters:
      repositories - This parameter is required.
      opts -
    • ecr

      @Stability(Stable) @NotNull public static DockerCredential ecr(@NotNull List<? extends IRepository> repositories)
      Creates a DockerCredential for one or more ECR repositories.

      NOTE - All ECR repositories in the same account and region share a domain name (e.g., 0123456789012.dkr.ecr.eu-west-1.amazonaws.com), and can only have one associated set of credentials (and DockerCredential). Attempting to associate one set of credentials with one ECR repo and another with another ECR repo in the same account and region will result in failures when using these credentials in the pipeline.

      Parameters:
      repositories - This parameter is required.
    • grantRead

      @Stability(Stable) public abstract void grantRead(@NotNull IGrantable grantee, @NotNull DockerCredentialUsage usage)
      Grant read-only access to the registry credentials.

      This grants read access to any secrets, and pull access to any repositories.

      Parameters:
      grantee - This parameter is required.
      usage - This parameter is required.
    • getUsages

      @Stability(Stable) @Nullable protected List<DockerCredentialUsage> getUsages()