Skip to content

Instantly share code, notes, and snippets.

@jess-belliveau
Created January 15, 2020 04:12
Show Gist options
  • Save jess-belliveau/7394cb9151840980a4a36de43f42ca93 to your computer and use it in GitHub Desktop.
Save jess-belliveau/7394cb9151840980a4a36de43f42ca93 to your computer and use it in GitHub Desktop.
KMS actions against nsmithuk/local-kms
# Show no existing keys
➜ aws kms list-keys --endpoint-url http://localhost:8080
{
"Keys": []
}
# Create an initial test key, no tags
➜ aws kms create-key --endpoint=http://localhost:8080
{
"KeyMetadata": {
"Origin": "AWS_KMS",
"KeyId": "ca3b5970-1100-4861-b9d9-9c83df257a13",
"Description": "",
"KeyManager": "CUSTOMER",
"Enabled": true,
"KeyUsage": "ENCRYPT_DECRYPT",
"KeyState": "Enabled",
"CreationDate": 1579061465,
"Arn": "arn:aws:kms:eu-west-2:111122223333:key/ca3b5970-1100-4861-b9d9-9c83df257a13",
"AWSAccountId": "111122223333"
}
}
# List returns single key as expected
➜ aws kms list-keys --endpoint-url http://localhost:8080
{
"Keys": [
{
"KeyArn": "arn:aws:kms:eu-west-2:111122223333:key/ca3b5970-1100-4861-b9d9-9c83df257a13",
"KeyId": "ca3b5970-1100-4861-b9d9-9c83df257a13"
}
]
}
# Create a new key with two tags
➜ aws kms create-key --tags TagKey=Tag1,TagValue=Test TagKey=Tag2,TagValue=Two --endpoint=http://localhost:8080
{
"KeyMetadata": {
"Origin": "AWS_KMS",
"KeyId": "3baeb469-c6f4-4e88-8551-94ce1ff2c159",
"Description": "",
"KeyManager": "CUSTOMER",
"Enabled": true,
"KeyUsage": "ENCRYPT_DECRYPT",
"KeyState": "Enabled",
"CreationDate": 1579061489,
"Arn": "arn:aws:kms:eu-west-2:111122223333:key/3baeb469-c6f4-4e88-8551-94ce1ff2c159",
"AWSAccountId": "111122223333"
}
}
# List returns two keys as expected
➜ aws kms list-keys --endpoint-url http://localhost:8080
{
"Keys": [
{
"KeyArn": "arn:aws:kms:eu-west-2:111122223333:key/3baeb469-c6f4-4e88-8551-94ce1ff2c159",
"KeyId": "3baeb469-c6f4-4e88-8551-94ce1ff2c159"
},
{
"KeyArn": "arn:aws:kms:eu-west-2:111122223333:key/ca3b5970-1100-4861-b9d9-9c83df257a13",
"KeyId": "ca3b5970-1100-4861-b9d9-9c83df257a13"
}
]
}
# Confirm two tags are present
➜ aws kms list-resource-tags --key-id 3baeb469-c6f4-4e88-8551-94ce1ff2c159 --endpoint-url http://localhost:8080
{
"Truncated": false,
"Tags": [
{
"TagKey": "Tag1",
"TagValue": "Test"
},
{
"TagKey": "Tag2",
"TagValue": "Two"
}
]
}
@jess-belliveau
Copy link
Author

Docker image logs:

➜ docker run -p 8080:8080 nsmithuk/local-kms

INFO[2020-01-15 04:10:19.184] No file found at path /init/seed.yaml; skipping seeding.
INFO[2020-01-15 04:10:19.184] Data will be stored in /data
INFO[2020-01-15 04:10:19.184] Local KMS started on 0.0.0.0:8080
INFO[2020-01-15 04:10:51.249] 0 keys listed
INFO[2020-01-15 04:11:05.674] New key created: arn:aws:kms:eu-west-2:111122223333:key/ca3b5970-1100-4861-b9d9-9c83df257a13
INFO[2020-01-15 04:11:12.604] 1 keys listed
INFO[2020-01-15 04:11:29.621] New key created: arn:aws:kms:eu-west-2:111122223333:key/3baeb469-c6f4-4e88-8551-94ce1ff2c159
INFO[2020-01-15 04:11:29.621] New tag created: Tag1 / Test
INFO[2020-01-15 04:11:29.622] New tag created: Tag2 / Two
INFO[2020-01-15 04:11:37.046] 2 keys listed
INFO[2020-01-15 04:12:36.041] 2 tags listed for key arn:aws:kms:eu-west-2:111122223333:key/3baeb469-c6f4-4e88-8551-94ce1ff2c159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment