You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Amazon VPC Lattice with AWS Lambda as weighted targets
2
+
3
+
This pattern demonstrates how to create a VPC Lattice which shifts traffic to different targets based on the weighted routing policy.
4
+
5
+
Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the [AWS Pricing page](https://aws.amazon.com/pricing/) for details. You are responsible for any AWS costs incurred. No warranty is implied in this example.
6
+
7
+
## Requirements
8
+
9
+
*[Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources.
10
+
*[AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured.
1. From the command line, initialize Terraform to downloads and install the providers defined in the configuration:
25
+
```
26
+
terraform init
27
+
```
28
+
1. From the command line, apply the configuration in the main.tf file:
29
+
```
30
+
terraform apply
31
+
```
32
+
1. Note the outputs from the deployment process. These contain the resource names and/or ARNs which are used for testing.
33
+
34
+
## How it works
35
+
36
+
VPC Lattice is to designed to help you easily and effectively discover, secure, connect, and monitor all of the services within it. Each component within VPC Lattice communicates unidirectionally or bi-directionally within the service network based on its association with the service network and its access settings. Access settings are comprised of authentication and authorization policies required for this communication.
37
+
38
+
This pattern creates below resources:
39
+
40
+
1. A new VPC with CIDR of 10.0.0.0/16
41
+
2. A private subnet
42
+
3. Security Group allowing inbound traffic from VPC CIDR 10.0.0.0/16
43
+
4. VPC Lattice service
44
+
5. VPC Lattice Listner
45
+
6. VPC Lattice Service Network
46
+
7. VPC Lattice Network Association and Service Association
47
+
8. Two Lambda functions (Primary and Secondary) to demonstrate traffic shift.
48
+
9. One Lambda function (Demo) to verify traffic shift by calling VPC lattice service DNS.
49
+
50
+
This pattern uses Lambda as weighted targets. VPC Lattice service shifts traffic based on the percentage of weight configured for target groups under VPC Lattice listener. User may update the weight for the targets according to their use case and requirements.
51
+
52
+
## Testing
53
+
54
+
Invoke Demo Lambda function using CLI/Console and observe traffice shift from VPC Lattice service.
55
+
56
+
## Cleanup
57
+
58
+
1. Change directory to the pattern directory:
59
+
```
60
+
cd vpc-lattice-lambda-tf
61
+
```
62
+
1. Delete all created resources by Terraform
63
+
```bash
64
+
terraform destroy
65
+
```
66
+
1. Confirm all created resources has been deleted
67
+
```bash
68
+
terraform show
69
+
```
70
+
----
71
+
Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
"title": "Amazon VPC Lattice with AWS Lambda as weighted targets",
3
+
"description": "This pattern demonstrates how to create a VPC Lattice which shifts traffic to different targets based on the weighted routing policy.",
4
+
"language": "YAML",
5
+
"level": "200",
6
+
"framework": "Terraform",
7
+
"introBox": {
8
+
"headline": "How it works",
9
+
"text": [
10
+
"VPC Lattice is to designed to help you easily and effectively discover, secure, connect, and monitor all of the services within it. Each component within VPC Lattice communicates unidirectionally or bi-directionally within the service network based on its association with the service network and its access settings. Access settings are comprised of authentication and authorization policies required for this communication.",
11
+
"This pattern uses Lambda as weighted targets. VPC Lattice service shifts traffic based on the percentage of weight configured for target groups under VPC Lattice listener. User may update the weight for the targets according to their use case and requirements."
0 commit comments