symfony / aws-key-management
Symfony AWS Key Management Bridge
Package info
github.com/symfony/aws-key-management
Type:symfony-key-management-bridge
pkg:composer/symfony/aws-key-management
Requires
- php: >=8.4.1
- async-aws/core: ^1.7
- async-aws/kms: ^1.0
- symfony/key-management: ^8.2
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-14 08:45:47 UTC
README
Provides an implementation of Symfony\Component\KeyManagement\EncrypterInterface and
Symfony\Component\KeyManagement\DataKeyGeneratorInterface backed by
AWS Key Management Service through the
lightweight async-aws/kms client. Encryption,
decryption and data-key generation never expose the master key: AWS performs
them server-side.
This Bridge is experimental. Experimental features are not covered by Symfony's Backward Compatibility Promise.
use AsyncAws\Core\Configuration; use AsyncAws\Kms\KmsClient; use Symfony\Component\KeyManagement\Bridge\AwsKms\AwsKms; $kms = new AwsKms(new KmsClient(Configuration::create([ 'region' => 'eu-west-1', // 'accessKeyId' / 'accessKeySecret' / 'sessionToken' are optional; // by default async-aws walks the standard credential provider chain. ]))); // Use the key ARN, key id, or alias (e.g. "alias/app-key"). $ciphertext = $kms->encrypt('alias/app-key', 'hello world'); $plaintext = $kms->decrypt($ciphertext); $dataKey = $kms->generateDataKey('alias/app-key', 32); $result = $dataKey->use(fn (string $dek): string => /* local AEAD encrypt */);
DSN scheme
aws-kms://[<accessKey>:<secretKey>@]<host>[:<port>]?region=<region>[&session_token=<token>]
The host default selects the public AWS endpoint for the given region;
any other host is treated as a custom endpoint (LocalStack, VPC endpoint,
...). Leaving the credentials out lets async-aws fall back to the
standard provider chain (env vars, instance profile, ...).
Examples:
aws-kms://default?region=eu-west-1
aws-kms://AKIA...:secret@default?region=us-east-1&session_token=TOKEN
aws-kms://localhost:4566?region=eu-west-1
AAD support
AWS KMS exposes additional authenticated data through EncryptionContext,
which is restricted to array<string, string>. To stay compatible with the
opaque-bytes contract of EncrypterInterface, this bridge stores the AAD as a
single base64-encoded entry under a conventional key. Cross-bridge
interoperability is therefore not guaranteed: a ciphertext produced by this
bridge with a non-empty AAD only round-trips through the same bridge.