Encrypt a proxy configuration with a customer managed key
Elastic Load Balancing for Envoy (ELB for Envoy) always encrypts your proxy's configuration file and configuration archive at rest. You have two options for the encryption key:
-
AWS owned key (default) – ELB for Envoy encrypts your configuration with an AWS owned key, and you don't need to set anything up. You can't view, manage, or audit AWS owned keys.
-
Customer managed key – ELB for Envoy encrypts your configuration with a key in AWS Key Management Service (AWS KMS) that you create and own. Its key policy controls access, and you can audit the key's use in AWS CloudTrail.
Proxy metadata, such as the proxy's name, tags, and attributes, isn't encrypted with your customer managed key.
How encryption with a customer managed key works
When you specify a customer managed key, ELB for Envoy uses envelope encryption. For each configuration version, it does the following:
-
Calls
GenerateDataKeyon your key. -
Encrypts your configuration with the returned data key.
-
Stores the encrypted configuration with the encrypted data key.
To read the configuration, ELB for Envoy calls Decrypt on your key to decrypt the
data key.
ELB for Envoy calls AWS KMS in two ways:
-
With your credentials, through forward access sessions, when you call
CreateProxy,UpdateProxyConfiguration, orGetProxyConfigurationContents. -
As the service principal
elasticloadbalancing.amazonaws.com, to deliver configuration to the proxy's nodes.
Every call uses an encryption context that binds the data key to one proxy. The context
key is aws:elasticloadbalancing:proxy-arn, and its value is the proxy ARN. A data
key issued for one proxy can't decrypt another proxy's configuration.
ELB for Envoy doesn't create grants on your key, doesn't require a customer-provided role, and doesn't cache data keys.
Key requirements
The customer managed key must meet all of the following requirements:
-
It's a symmetric encryption key (
SYMMETRIC_DEFAULTkey spec,ENCRYPT_DECRYPTkey usage). -
It's enabled.
-
It's in the same AWS account and Region as the proxy. Multi-Region keys aren't supported.
Specify the full key ARN. Key IDs and aliases aren't accepted.
When a request sets a key, or an update keeps the proxy's current key, ELB for Envoy calls
DescribeKey and a Decrypt with DryRun to check the key
and your key policy. If either check fails, the request fails. See Errors.
Key policy
The key policy must allow two principals to use the key:
-
The role that calls the ELB for Envoy APIs. It needs
kms:DescribeKey,kms:GenerateDataKey, andkms:Decrypt. -
The ELB for Envoy service principal,
elasticloadbalancing.amazonaws.com, which decrypts your configuration to deliver it to the proxy's nodes.
The following example key policy grants the permissions that ELB for Envoy needs.
{ "Version": "2012-10-17", "Id": "elb-for-envoy-proxy-configuration-key-policy", "Statement": [ { "Sid": "EnableKeyAdministration", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:root" }, "Action": "kms:*", "Resource": "*" }, { "Sid": "AllowElbForEnvoyToDescribeKey", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:role/ProxyAdminRole" }, "Action": "kms:DescribeKey", "Resource": "*", "Condition": { "StringEquals": { "kms:ViaService": "elasticloadbalancing.us-east-1.amazonaws.com", "kms:CallerAccount": "123456789012" } } }, { "Sid": "AllowElbForEnvoyToEncryptAndDecryptProxyConfiguration", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:role/ProxyAdminRole" }, "Action": ["kms:GenerateDataKey", "kms:Decrypt"], "Resource": "*", "Condition": { "StringEquals": { "kms:ViaService": "elasticloadbalancing.us-east-1.amazonaws.com", "kms:CallerAccount": "123456789012" }, "StringLike": { "kms:EncryptionContext:aws:elasticloadbalancing:proxy-arn": "arn:aws:elasticloadbalancing:us-east-1:123456789012:proxy/*" } } }, { "Sid": "AllowElbForEnvoyToDecryptForProxyNodes", "Effect": "Allow", "Principal": { "Service": "elasticloadbalancing.amazonaws.com" }, "Action": "kms:Decrypt", "Resource": "*", "Condition": { "StringEquals": { "aws:SourceAccount": "123456789012" }, "ArnLike": { "aws:SourceArn": "arn:aws:elasticloadbalancing:us-east-1:123456789012:proxy/*" }, "StringLike": { "kms:EncryptionContext:aws:elasticloadbalancing:proxy-arn": "arn:aws:elasticloadbalancing:us-east-1:123456789012:proxy/*" } } } ] }
Replace the following tokens:
-
123456789012with your AWS account ID. -
us-east-1with the proxy's Region. -
ProxyAdminRolewith the role that calls the ELB for Envoy APIs.
Each statement grants the following:
-
EnableKeyAdministration– Gives your account full control of the key. Scope it to your key administrators as your security practices require. -
AllowElbForEnvoyToDescribeKey– Validates the key when a request specifies it. -
AllowElbForEnvoyToEncryptAndDecryptProxyConfiguration– Creates data keys, runs theDryRuncheck, re-encrypts during key changes, and returns configuration fromGetProxyConfigurationContents. -
AllowElbForEnvoyToDecryptForProxyNodes– Decrypts data keys to deliver configuration to the proxy's nodes.
Scope down access to the key
The example key policy uses the following conditions to limit access to the key:
-
kms:ViaService(elasticloadbalancing.) limits calls made with your credentials to ELB for Envoy.us-east-1.amazonaws.com -
The encryption context key
aws:elasticloadbalancing:proxy-arnis set to the proxy ARN on everyGenerateDataKeyandDecrypt. Use it to limit the key to all proxies or to specific proxies. -
aws:SourceArnandaws:SourceAccountare set on calls that the service principal makes, which protects against the confused deputy problem.
To limit the key to one proxy, replace every proxy/* in the key policy with
the following value. Replace my-proxy with the name of your
proxy.
"arn:aws:elasticloadbalancing:us-east-1:123456789012:proxy/my-proxy/*"
These conditions apply to the key policy statements. If you also grant key access through
IAM policies, add the same kms:ViaService and encryption context conditions to
those policies.
Create a customer managed key
Create a key using the console, the AWS CLI, or CloudFormation. Choose the tab for the method that you want to use.
Create a proxy with a customer managed key
Create a proxy with a customer managed key using the console, the AWS CLI, or CloudFormation. Choose the tab for the method that you want to use.
Verify the key that a proxy uses
Verify the key that a proxy uses with the console or the AWS CLI. Choose the tab for the method that you want to use.
Viewing a key is a read operation, so this task has no CloudFormation method.
Change or remove the key
You can set a key on an existing proxy, rotate to a different key, or switch to the AWS owned key. Choose the tab for the method that you want to use.
ELB for Envoy doesn't re-encrypt previous configuration versions. Each version stays encrypted under the key that was in use when you created it. ELB for Envoy deletes previous versions after about 4 days. If the most recent previous version uses the same key as the current version, ELB for Envoy keeps it so that it can roll back to it.
You can't read previous versions through the ELB for Envoy APIs. If you disable or delete a previous key, you can't decrypt the versions encrypted under it.
When ELB for Envoy can't use your key
If you disable or delete the key, or remove the permissions that ELB for Envoy needs, the following happens:
-
The proxy's status becomes
action-required, with the reasonCustomerKmsKeyInaccessible. The message names the key and the AWS KMS error. -
Running nodes keep serving their current configuration, but new configuration versions and new nodes can't get configuration.
-
If the key is disabled or deleted,
GetProxyConfigurationContentsand updates fail withValidationException. If your principal's permissions are removed, they fail withAccessDeniedException. If only the service principal's permissions are removed, these calls still succeed, but the nodes can't decrypt the new configuration.
When you restore access, the reason clears and the proxy returns to its previous status. If you delete the key, configuration encrypted with it can't be recovered. Update the proxy with new configuration and another key, or with no key.
Errors
The following table lists common encryption errors, their causes, and how to fix them.
| Error | Cause | Fix |
|---|---|---|
ValidationException: key not usable |
The key doesn't exist, is disabled, or is pending deletion. | Check the key ARN and Region, and make sure the key is enabled. |
ValidationException: key not symmetric |
The key is asymmetric. | Use a SYMMETRIC_DEFAULT key. |
ValidationException: wrong key usage |
The key usage isn't encrypt and decrypt. | Create the key with ENCRYPT_DECRYPT usage. |
ValidationException: multi-Region key |
The key is a multi-Region key. | Use a single-Region key. |
AccessDeniedException on GenerateDataKey or
Decrypt |
The key policy doesn't grant the caller or the service principal. | Apply the key policy in Key policy. |
The proxy's status is action-required with the reason
CustomerKmsKeyInaccessible |
The key is disabled or deleted, or the key policy no longer grants your role or the service principal. | Restore the key or the AllowElbForEnvoyToDecryptForProxyNodes
statement. See When ELB for Envoy can't use your key. |
Monitor key use with AWS CloudTrail
You can audit how ELB for Envoy uses your key in AWS CloudTrail. For more information, see Logging AWS KMS API calls with AWS CloudTrail.
| eventName | When | Caller |
|---|---|---|
DescribeKey and Decrypt (dryRun) |
CreateProxy or UpdateProxyConfiguration that sets a key,
or an update that keeps the proxy's current key |
Your principal |
GenerateDataKey |
CreateProxy, UpdateProxyConfiguration |
Your principal |
Decrypt |
GetProxyConfigurationContents, once per component returned;
UpdateProxyConfiguration, once per component carried over from the current
configuration |
Your principal |
Decrypt |
Each time a node fetches its configuration | elasticloadbalancing.amazonaws.com, with sourceArn and
sourceAccount |
Each event's encryptionContext is set to the proxy ARN:
{"aws:elasticloadbalancing:proxy-arn": "arn:aws:elasticloadbalancing:us-east-1:123456789012:proxy/my-proxy/0123456789abcdef"}