Provision local application secrets before tests, load JSON fixtures, and manage development secrets. Task types live in io.github.gregwhitaker.awsemulator.aws.secretsmanager.

Provision Before Tests

Kotlin DSL

import io.github.gregwhitaker.awsemulator.aws.secretsmanager.PutSecretsTask

plugins {
    java
    id("io.github.gregwhitaker.aws-emulator") version "0.3.0"
}

val secrets = tasks.register<PutSecretsTask>("seedSecrets") {
    fixtures.set(layout.projectDirectory.file("fixtures/secrets.json"))
}
val tests = tasks.named<Test>("test") { dependsOn(secrets) }
awsEmulator { useWith(tests) }

Groovy DSL

import io.github.gregwhitaker.awsemulator.aws.secretsmanager.PutSecretsTask

plugins {
    id 'java'
    id 'io.github.gregwhitaker.aws-emulator' version '0.3.0'
}

def secrets = tasks.register('seedSecrets', PutSecretsTask) {
    fixtures.set(layout.projectDirectory.file('fixtures/secrets.json'))
}
def tests = tasks.named('test') { dependsOn(secrets) }
awsEmulator { useWith(tests) }

Task Properties

Task type Configuration

PutSecretTask

secretName, value string, optional keyId, overwrite (default false)

PutSecretsTask

fixtures JSON file, overwrite

ListSecretsTask

Lists secret names, including secrets scheduled for deletion

DescribeSecretTask

secretName; prints ARN and deletion date without the value

DeleteSecretsTask

Explicit names, recoveryWindowInDays (7–30; default 30), force (default false)

Fixture Format

fixtures/secrets.json
[
  {"name":"app/database","value":"{\"username\":\"local\",\"password\":\"local-only\"}"}
]

Every entry requires string name and value, with an optional keyId. Declare a dependency on CreateKmsKeyTask when referring to a custom key alias. Secret strings allow up to 65536 UTF-8 bytes. Binary secrets, secret rotation, and version-stage management are outside these task types.

Fixtures must be nonempty JSON arrays no larger than 16 MiB. Unknown fields, duplicate JSON keys, duplicate resource names, malformed JSON, and invalid entries fail before starting Docker. All entries are validated before provisioning; service calls then run sequentially. A service failure reports the failing name and number of completed entries. Earlier changes remain in a development instance. No automatic rollback is attempted.

Reuse And Overwrite Behavior

Identical values are reused without creating new versions. Different values require overwrite=true. Explicit key identifiers are compared with the identifier reported by the service; consistently use the same key ID or alias. Provisioning never restores a secret scheduled for deletion. Metadata commands and provisioning errors omit values; applications read values through their SDKs.

Development Commands

./gradlew listSecrets
./gradlew describeSecret --secretName=app/database
./gradlew deleteSecrets --names=app/database

Select names for deletion with repeated --names options. Deletion defaults to a 30-day recovery window; recoveryWindowInDays accepts 7–30 days, and --force requests asynchronous deletion without recovery. Stopping a managed emulator discards its entire in-memory state immediately.

Runtime Selection

Custom resource tasks inherit awsEmulator.defaultMode, initially MANAGED. Make the consuming test or application task depend on provisioning and opt that consumer in with awsEmulator.useWith(…​). Provisioning and consumers must select the same runtime name and mode; see resource task defaults to configure a shared development default.

Every task accepts runtimeName (default default), mode, and apiCallTimeoutSeconds (default 30, positive). Predefined inspection and deletion commands default to DEVELOPMENT; select another mode with --mode=MANAGED or another declared runtime with --runtime <name>. For persistent setup, see development resource tasks.

Resource tasks always execute against live emulator state and do not use the build cache. Configuration-cache reuse is supported. Applying the plugin and listing tasks do not start Docker. Task input values may be stored in Gradle’s configuration cache; fixtures should contain local test values.

Runnable Example

./gradlew -p examples/services verifyServices --configuration-cache

The example seeds a database secret from JSON and reads its value using AWS SDK for Java v2. Run the command twice to check configuration-cache reuse against a fresh managed emulator. -PfailExample=true deliberately fails the application test to demonstrate cleanup. See the runnable example for its complete setup and persistent development commands.

Verified Scope

The examples exercise these workflows against the pinned AWS Emulator 1.0.385, using AWS SDK for Java v2 2.39.6. They establish the behavior used by these tasks, not complete AWS service equivalence. AWS Emulator fidelity varies by operation and release.