Guillaume Coré
2020-03-11 1d970fbaa4bd88c9d094d9587db59fdf9cd0239a
commit | author | age
7961b2 1 = VPC Peering in AWS
GC 2
3 A VPC peering connection is a networking connection between two VPCs that enables you to route traffic between them using private IPv4 addresses or IPv6 addresses. Instances in either VPC can communicate with each other as if they are within the same network. You can create a VPC peering connection between your own VPCs, or with a VPC in another AWS account. The VPCs can be in different regions (also known as an inter-region VPC peering connection).
4
5 Upstream documentation about VPC Peering: https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html
6
7
8 == Role Input variables
9
10 |=================
11 | Variable | Usage
12 | `vpc_region`
13 | The region of the requester, for example `us-east-1`
14 | `peer_region`
15 | The other region to connect to, for example `eu-central-1`
16 | `vpc_private_zone` (optional)
17 | The name of the private zone of the first region. For example: `na.guid.internal.`
18
19 If you set a value for this variable, the *second* VPC will be associated to the private zone of first region. This way, second VPC can resolve names of the first private DNS zone.
20 | `peer_private_zone` (optional)
21 | The name of the private zone of the second region. For example: `emea.guid.internal.`
22
23 If you set a value for this variable, the *first* VPC will be associated to the private zone of *second* region. This way, first VPC can resolve names of the second private DNS zone.
24 | `project_tag`
25 | Name of the Cloudformation stacks to connect. Most of the time, this variable is already defined at top level in AgnosticD runs. Both stacks must have the same name.
26 |=================
27
28
29 == Examples
30
31 [source,yaml]
32 .Simple example.
33 ----
34 - include_role:
35     name: infra-ec2-vpc-peering
36   vars:
37     vpc_region: us-east-1
38     peer_region: eu-central-1
39     vpc_private_zone: na.guid.internal.
40     peer_private_zone: emea.guid.internal.
41 ----
42
43 [source,yaml]
44 .Complex example to connect every regions to each others.
45 ----
46 - include_role:
47     name: infra-ec2-vpc-peering
48   vars:
49     vpc_region: "{{ _region[0].region }}"
50     peer_region: "{{ _region[1].region }}"
51     vpc_private_zone: "{{ _region[0].name }}.{{ guid }}.internal."
52     peer_private_zone: "{{ _region[1].name }}.{{ guid }}.internal."
53   loop: "{{ target_regions | product(target_regions) | list }}"
54   loop_control:
55     loop_var: _region
56   when:
57     - _region[0].region != _region[1].region
58     - _region[0].region < _region[1].region
59 ----