I am using spring data for connectivity like below:
@Bean
public AmazonDynamoDB amazonDynamoDB() {
BasicAWSCredentials credentials = new BasicAWSCredentials(ACCESS_KEY,
SECRET_KEY);
final AmazonDynamoDBClient client = new
AmazonDynamoDBClient(credentials);
client.withEndpoint(END_POINT);
//client.withRegion(Regions.AP_SOUTH_1);
client.withRegion(Regions.US_WEST_2);
return client;
}
But i am facing Caused by: org.apache.http.conn.ConnectTimeoutException: Connect
to dynamodb.us-west-2.amazonaws.com:443
From EC2 instance with public subnet it is working fine.
Please suggest how can i access DynamoDB from ec2 instance with private subnet.
You can't connect to DynamoDB or many other AWS services (SQS or SNS, for example) from an instance on a private subnet without a NAT Gateway or a NAT Instance.
NAT
You can use a NAT device to enable instances in a private subnet to connect to the Internet (for example, for software updates) or other AWS services, but prevent the Internet from initiating connections with the instances. A NAT device forwards traffic from the instances in the private subnet to the Internet or other AWS services, and then sends the response back to the instances. When traffic goes to the Internet, the source IP address is replaced with the NAT device's address and similarly, when the response traffic goes to those instances, the NAT device translates the address back to those instances' private IP addresses.
http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-nat.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.