https://github.com/donaldkellett/aws-multi-region-demo
AWS multi-region infrastructure with VPC peering
https://github.com/donaldkellett/aws-multi-region-demo
aws opentofu opentofu-modules
Last synced: 3 months ago
JSON representation
AWS multi-region infrastructure with VPC peering
- Host: GitHub
- URL: https://github.com/donaldkellett/aws-multi-region-demo
- Owner: DonaldKellett
- License: apache-2.0
- Created: 2024-05-04T04:22:44.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-04T08:46:23.000Z (about 1 year ago)
- Last Synced: 2025-01-10T07:43:26.317Z (4 months ago)
- Topics: aws, opentofu, opentofu-modules
- Language: HCL
- Homepage:
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# aws-multi-region-demo
AWS multi-region infrastructure with VPC peering
## Architecture

## Developing
### Dependencies
- [AWS CLI v2](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) installed and configured with admin access to a valid AWS account
- [OpenTofu](https://opentofu.org/) 1.7.x or later### Pre-commit hook
A pre-commit hook `hooks/pre-commit` is provided to detect and fix formatting issues prior to committing and pushing your changes.
To use the pre-commit hook, create a symlink `./.git/hooks/pre-commit` pointing to the script:
```bash
ln -s ../../hooks/pre-commit ./.git/hooks/pre-commit
```### Running the demo
Fork and clone this repository, then navigate to the project root and run:
```bash
tofu init
tofu plan
tofu apply
```Upon resource creation, the public and private IP address of EC2 instances across both regions are displayed in the console, e.g.:
```text
my-primary-ec2-private-ip = "x.x.x.x"
my-primary-ec2-public-ip = "x.x.x.x"
my-secondary-ec2-private-ip = "x.x.x.x"
my-secondary-ec2-public-ip = "x.x.x.x"
```Now log in to each EC2 instance via SSH with username `ubuntu` and the corresponding public IP address, then confirm that they can ping each other's private IP address.
### Supported variables
Refer to the table below for a list of supported OpenTofu variables:
| Name | Type | Required | Default value | Description |
| --- | --- | --- | --- | --- |
| `primary_region` | `string` | - | `"ap-east-1"` | Primary AWS region |
| `secondary_region` | `string` | - | `"ap-southeast-1"` | Secondary AWS region |
| `primary_vpc_cidr` | `string` | - | `"10.1.0.0/16"` | VPC CIDR block for primary AWS region. Must be an [RFC 1918](https://datatracker.ietf.org/doc/html/rfc1918) subnet |
| `secondary_vpc_cidr` | `string` | - | `"10.2.0.0/16"` | VPC CIDR block for secondary AWS region. Must be an [RFC 1918](https://datatracker.ietf.org/doc/html/rfc1918) subnet |
| `primary_subnet_cidr` | `string` | - | `"10.1.1.0/24"` | Subnet CIDR block for primary AWS region. Must be a valid subnet of the primary VPC CIDR block |
| `secondary_subnet_cidr` | `string` | - | `"10.2.1.0/24"` | Subnet CIDR block for secondary AWS region. Must be a valid subnet of the secondary VPC CIDR block |
| `ssh_pubkey_path` | `string` | - | `"~/.ssh/id_rsa.pub"` | Path to your SSH public key. Evaluated with `pathexpand()` before use |
| `instance_type` | `string` | - | `"t3.micro"` | EC2 instance type for both regions |## License
[Apache 2.0](./LICENSE)