Using Secrets Manager with VPC endpoints
Instead of connecting your VPC to an internet, you can connect directly to Secrets Manager through a private endpoint you configure within your VPC. When you use a VPC service endpoint, communication between your VPC and Secrets Manager occurs entirely within the AWS network, and requires no public Internet access.
Secrets Manager supports Amazon VPC interface endpoints provided by AWS PrivateLink. Each VPC endpoint is represented by one or more elastic network interfaces with private IP addresses in your VPC subnets.
For information about permissions policies and VPCs, see Example: Permissions and VPCs.
The VPC interface endpoint connects your VPC directly to Secrets Manager without a NAT device, VPN connection, or AWS Direct Connect connection. The instances in your VPC don't require public IP addresses to communicate with Secrets Manager.
For your Lambda rotation function to find the private endpoint, perform one of the following steps:
-
You can manually specify the VPC endpoint in Secrets Manager API operations and AWS CLI commands. For example, the following command uses the endpoint-url parameter to specify a VPC endpoint in an AWS CLI command to Secrets Manager. For more information, see AWS CLI command line options.
$aws secretsmanager list-secrets --endpoint-url https://vpce-1234a5678b9012c-12345678.secretsmanager.us-west-2.vpce.amazonaws.com -
If you enable private DNS hostnames for your VPC private endpoint, you don't need to specify the endpoint URL. The standard Secrets Manager DNS hostname the Secrets Manager CLI and SDKs use by default (
https://secretsmanager.<region>.amazonaws.com) automatically resolves to your VPC endpoint.
You can also use AWS CloudTrail logs to audit your use of secrets through the VPC endpoint. And you can use the conditions in IAM and secret resource-based policies to deny access to any request that doesn't originate from a specified VPC or VPC endpoint.
Use caution when creating IAM and key policies based on your VPC endpoint. If a policy statement requires the requests originate from a particular VPC or VPC endpoint, then requests from other AWS services interacting with the secret on your behalf might fail. For help, see VPC endpoint conditions.
Regions
Secrets Manager supports VPC endpoints in all AWS Regions where both Amazon VPC and Secrets Manager are available.
For more information, see VPC Endpoints.
To create a Secrets Manager VPC private endpoint
Follow the steps under one of the following tabs:
Connecting to a Secrets Manager VPC private endpoint
Because, by default, VPC automatically enables private DNS names when you create a VPC private endpoint, you don't need to do anything other than use the standard endpoint DNS name for your region. The endpoint DNS name automatically resolves to the correct endpoint within your VPC:
https://secretsmanager.<region>.amazonaws.com
The AWS CLI and SDKs use this hostname by default, so you can begin using the VPC endpoint without changing anything in your scripts and application.
If you don't enable private DNS names, you can still connect to the endpoint by using the full DNS name.
For example, this list-secrets command uses the endpoint-url parameter to specify the
VPC private endpoint. To use a command like this, replace the example VPC private
endpoint ID
with one in your account.
aws secretsmanager list-secrets --endpoint-urlhttps://vpce-1234a5678b9012c-12345678.secretsmanager.us-west-2.vpce.amazonaws.com
Audit the use of your Secrets Manager VPC endpoint
When a request to Secrets Manager uses a VPC endpoint, the VPC endpoint ID appears in the AWS CloudTrail log entry that records the request. You can use the endpoint ID to audit the use of your Secrets Manager VPC endpoint.
For example, this sample log entry records a GenerateDataKey request that
used the VPC endpoint. In this example, the vpcEndpointId field appears at the
end of the log entry. For brevity, many irrelevant parts of the example have been
omitted.
{ "eventVersion":"1.05", "userIdentity": { "type": "IAMUser", "arn": "arn:aws:iam::123456789012:user/Anika", "accountId": "123456789012", "userName": "Anika" }, "eventTime":"2018-01-16T05:46:57Z", "eventSource":"secretsmanager.amazonaws.com", "eventName":"GetSecretValue", "awsRegion":"us-west-2", "sourceIPAddress":"172.01.01.001", "userAgent":"aws-cli/1.14.23 Python/2.7.12 Linux/4.9.75-25.55.amzn1.x86_64 botocore/1.8.27", "requestID":"EXAMPLE1-90ab-cdef-fedc-ba987EXAMPLE", "eventID":"EXAMPLE2-90ab-cdef-fedc-ba987EXAMPLE", "readOnly":true, "eventType":"AwsApiCall", "recipientAccountId":"123456789012","vpcEndpointId": "vpce-1234a5678b9012c"}

