DNS Configuration Conditioning :

- Add AWS_R53_ENABLED variable
- Update Documentation
- Add ToDo
This commit is contained in:
Damien A
2024-01-02 19:32:23 +01:00
parent fb2e5422c2
commit 22072de929
6 changed files with 21 additions and 3 deletions

View File

@@ -2,6 +2,11 @@
This project automates the deployment of ContainerLab on an AWS EC2 instance using Terraform for infrastructure provisioning and Ansible for software setup and configuration. It also configures a Route53 DNS record for easy access to the ContainerLab instance. This project automates the deployment of ContainerLab on an AWS EC2 instance using Terraform for infrastructure provisioning and Ansible for software setup and configuration. It also configures a Route53 DNS record for easy access to the ContainerLab instance.
## To Do
- [ ] Improving documentation
- [ ] Complete DNS configuration conditioning
## Prerequisites ## Prerequisites
Before you begin, ensure you have the following prerequisites installed and configured: Before you begin, ensure you have the following prerequisites installed and configured:
@@ -84,7 +89,12 @@ The `network_images` folder is intended for Docker images that will be used by C
- You can access the ContainerLab instance via SSH using the public IP or the DNS name provided by Route53. - You can access the ContainerLab instance via SSH using the public IP or the DNS name provided by Route53.
- The public IP of the instance can be found in the Terraform output. - The public IP of the instance can be found in the Terraform output.
- The DNS name will be in the format containerlab `<your_route53_zone_name>` - The DNS name will be in the format containerlab `<your_route53_zone_name>`.
> :warning: **ROUTE 53**
> By default, Route 53 is disabled to avoid errors in case of incomplete configuration.
> To enable it, modify the variables: `AWS_R53_ENABLED` and `AWS_R53_ZONE_ID`.
> In any case, `AWS_R53_ZONE_ID` need to be configured.
## Customization ## Customization

View File

@@ -33,6 +33,9 @@ resource "aws_instance" "containerlab_host" {
instance_type = var.INSTANCE_TYPE instance_type = var.INSTANCE_TYPE
key_name = var.AWS_KEY_NAME key_name = var.AWS_KEY_NAME
vpc_security_group_ids = [aws_security_group.netlab_sg.id] vpc_security_group_ids = [aws_security_group.netlab_sg.id]
tags = {
Name = "ContainerLab"
}
root_block_device { root_block_device {
volume_size = "128" volume_size = "128"

View File

@@ -3,5 +3,5 @@ output "public_ip" {
} }
output "containerlab_fqdn" { output "containerlab_fqdn" {
value = "${aws_route53_record.containerlab_fqdn.name}.${data.aws_route53_zone.selected.name}" value = var.AWS_R53_ENABLED && length(aws_route53_record.containerlab_fqdn) > 0 ? "${aws_route53_record.containerlab_fqdn[0].name}.${data.aws_route53_zone.selected.name}" : ""
} }

View File

@@ -2,8 +2,8 @@ data "aws_route53_zone" "selected" {
zone_id = var.AWS_R53_ZONE_ID zone_id = var.AWS_R53_ZONE_ID
} }
resource "aws_route53_record" "containerlab_fqdn" { resource "aws_route53_record" "containerlab_fqdn" {
count = var.AWS_R53_ENABLED ? 1 : 0
zone_id = var.AWS_R53_ZONE_ID zone_id = var.AWS_R53_ZONE_ID
name = "containerlab" name = "containerlab"
type = "A" type = "A"

View File

@@ -2,4 +2,5 @@ AWS_ACCESS_KEY = "YOURACCESSKEY"
AWS_SECRET_KEY = "YOURACCESSTOKEN" AWS_SECRET_KEY = "YOURACCESSTOKEN"
AWS_KEY_NAME = "AWS_key_name" AWS_KEY_NAME = "AWS_key_name"
AWS_KEY_LOCATION = "~/.ssh/aws_key.pem" AWS_KEY_LOCATION = "~/.ssh/aws_key.pem"
AWS_R53_ENABLED = "false"
AWS_R53_ZONE_ID = "R53_ZONE_ID" AWS_R53_ZONE_ID = "R53_ZONE_ID"

View File

@@ -3,6 +3,10 @@ variable "AWS_SECRET_KEY" {}
variable "AWS_KEY_NAME" {} variable "AWS_KEY_NAME" {}
variable "AWS_KEY_LOCATION" {} variable "AWS_KEY_LOCATION" {}
variable "AWS_R53_ZONE_ID" {} variable "AWS_R53_ZONE_ID" {}
variable "AWS_R53_ENABLED" {
type = bool
default = false
}
variable "GITHUB_REPO_URL" { variable "GITHUB_REPO_URL" {
type = string type = string