# ExternalDockerCredentialOptions

Options for defining credentials for a Docker Credential.

Used as argument in: [DockerCredential.customRegistry](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines.DockerCredential.html#customregistry), [DockerCredential.dockerHub](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines.DockerCredential.html#dockerhub)

- Source: [`pipelines/lib/docker-credentials.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/pipelines/lib/docker-credentials.ts#L68)

## Example

TypeScript:

```ts
const dockerHubSecret = secretsmanager.Secret.fromSecretCompleteArn(
  this,
  'DHSecret',
  'arn:aws:...'
);
// Only the image asset publishing actions will be granted read access to the secret.
const creds = pipelines.DockerCredential.dockerHub(dockerHubSecret, {
  usages: [pipelines.DockerCredentialUsage.ASSET_PUBLISHING],
});
```

Python:

```python
docker_hub_secret = secretsmanager.Secret.from_secret_complete_arn(self, "DHSecret", "arn:aws:...")
# Only the image asset publishing actions will be granted read access to the secret.
creds = pipelines.DockerCredential.docker_hub(docker_hub_secret,
    usages=[pipelines.DockerCredentialUsage.ASSET_PUBLISHING]
)
```

Java:

```java
ISecret dockerHubSecret = Secret.fromSecretCompleteArn(this, "DHSecret", "arn:aws:...");
// Only the image asset publishing actions will be granted read access to the secret.
DockerCredential creds = DockerCredential.dockerHub(dockerHubSecret, ExternalDockerCredentialOptions.builder()
        .usages(List.of(DockerCredentialUsage.ASSET_PUBLISHING))
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var dockerHubSecret = Secret.FromSecretCompleteArn(this, "DHSecret", "arn:aws:...");
// Only the image asset publishing actions will be granted read access to the secret.
var creds = DockerCredential.DockerHub(dockerHubSecret, new ExternalDockerCredentialOptions {
    Usages = new [] { DockerCredentialUsage.ASSET_PUBLISHING }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
dockerHubSecret := secretsmanager.Secret_FromSecretCompleteArn(this, jsii.String("DHSecret"), jsii.String("arn:aws:..."))
// Only the image asset publishing actions will be granted read access to the secret.
creds := pipelines.DockerCredential_DockerHub(dockerHubSecret, &ExternalDockerCredentialOptions{
	Usages: []DockerCredentialUsage{
		pipelines.DockerCredentialUsage_ASSET_PUBLISHING,
	},
})
```

## Properties

- `assumeRole`: [IRole](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — An IAM role to assume prior to accessing the secret.

  **Default:** none. The current execution role will be used.

- `secretPasswordField`: string = 'secret' — The name of the JSON field of the secret which contains the secret/password.

- `secretUsernameField`: string = 'username' — The name of the JSON field of the secret which contains the user/login name.

- `usages`: [DockerCredentialUsage](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines.DockerCredentialUsage.html)[] — Defines which stages of the pipeline should be granted access to these credentials.

  **Default:** all relevant stages (synth, self-update, asset publishing) are granted access.
