Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ module "automq-byoc" {

# Set the target regionId of aws
cloud_provider_region = "ap-southeast-1"

# Optional: Add additional tags to all resources
additional_tags = {
Environment = "Production"
Project = "MyProject"
Owner = "TeamA"
CostCenter = "Engineering"
}
}

# Necessary outputs
Expand Down Expand Up @@ -246,6 +254,7 @@ output "automq_byoc_instance_id" {
| <a name="input_automq_byoc_env_console_key_name"></a> [automq_byoc_env_console_key_name](#input_automq_byoc_env_console_key_name) | Specify the key pair name for accessing the AutoMQ BYOC environment console. If not specified, the console will be deployed without a key pair. | `string` | `""` | no |
| <a name="input_use_custom_ami"></a> [use_custom_ami](#input_use_custom_ami) | The parameter defaults to false, which means a specific AMI is not specified. If you wish to use a custom AMI, set this parameter to true and specify the `automq_byoc_env_console_ami` parameter with your custom AMI ID. | `bool` | `false` | no |
| <a name="input_automq_byoc_env_console_ami"></a> [automq_byoc_env_console_ami](#input_automq_byoc_env_console_ami) | When the `use_custom_ami` parameter is set to true, this parameter must be set with a custom AMI Name to deploy the AutoMQ console. | `string` | `""` | no |
| <a name="input_additional_tags"></a> [additional_tags](#input_additional_tags) | Additional tags to apply to all resources created by this module. | `map(string)` | `{}` | no |

## Outputs

Expand Down
114 changes: 49 additions & 65 deletions aws.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ module "automq_byoc_data_bucket_name" {
bucket = "automq-data-${var.automq_byoc_env_id}"
force_destroy = true

tags = {
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = local.common_tags
}

# Conditional creation of ops bucket
Expand All @@ -26,10 +23,7 @@ module "automq_byoc_ops_bucket_name" {
bucket = "automq-ops-${var.automq_byoc_env_id}"
force_destroy = true

tags = {
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = local.common_tags
}

data "aws_availability_zones" "available_azs" {}
Expand All @@ -54,10 +48,7 @@ module "automq_byoc_vpc" {
enable_nat_gateway = true
single_nat_gateway = true

tags = {
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = local.common_tags
}

resource "aws_security_group" "vpc_endpoint_sg" {
Expand All @@ -80,11 +71,12 @@ resource "aws_security_group" "vpc_endpoint_sg" {
cidr_blocks = ["0.0.0.0/0"]
}

tags = {
Name = "automq-byoc-endpoint-sg-${var.automq_byoc_env_id}"
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = merge(
local.common_tags,
{
Name = "automq-byoc-endpoint-sg-${var.automq_byoc_env_id}"
}
)
}

resource "aws_vpc_endpoint" "ec2_endpoint" {
Expand All @@ -98,11 +90,12 @@ resource "aws_vpc_endpoint" "ec2_endpoint" {

private_dns_enabled = true

tags = {
Name = "automq-byoc-ec2-endpoint-${var.automq_byoc_env_id}"
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = merge(
local.common_tags,
{
Name = "automq-byoc-ec2-endpoint-${var.automq_byoc_env_id}"
}
)
}

resource "aws_vpc_endpoint" "s3_endpoint" {
Expand All @@ -117,11 +110,12 @@ resource "aws_vpc_endpoint" "s3_endpoint" {
module.automq_byoc_vpc[0].private_route_table_ids
)

tags = {
Name = "automq-byoc-s3-endpoint-${var.automq_byoc_env_id}"
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = merge(
local.common_tags,
{
Name = "automq-byoc-s3-endpoint-${var.automq_byoc_env_id}"
}
)
}

resource "aws_vpc_endpoint" "s3table_endpoint" {
Expand All @@ -135,11 +129,12 @@ resource "aws_vpc_endpoint" "s3table_endpoint" {

private_dns_enabled = true

tags = {
Name = "automq-byoc-ec2-endpoint-${var.automq_byoc_env_id}"
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = merge(
local.common_tags,
{
Name = "automq-byoc-s3table-endpoint-${var.automq_byoc_env_id}"
}
)
}

resource "aws_vpc_endpoint" "glue_endpoint" {
Expand All @@ -153,11 +148,12 @@ resource "aws_vpc_endpoint" "glue_endpoint" {

private_dns_enabled = true

tags = {
Name = "automq-byoc-ec2-endpoint-${var.automq_byoc_env_id}"
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = merge(
local.common_tags,
{
Name = "automq-byoc-glue-endpoint-${var.automq_byoc_env_id}"
}
)
}

locals {
Expand All @@ -166,6 +162,15 @@ locals {
automq_data_bucket = var.automq_byoc_data_bucket_name == "" ? module.automq_byoc_data_bucket_name.s3_bucket_id : "${var.automq_byoc_data_bucket_name}"
automq_ops_bucket = var.automq_byoc_ops_bucket_name == "" ? module.automq_byoc_ops_bucket_name.s3_bucket_id : "${var.automq_byoc_ops_bucket_name}"
zone_id = aws_route53_zone.private_r53.zone_id

# Common tags that will be applied to all resources
common_tags = merge(
{
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
},
var.additional_tags
)
}

data "aws_vpc" "vpc_id" {
Expand Down Expand Up @@ -211,10 +216,7 @@ resource "aws_security_group" "automq_byoc_console_sg" {
cidr_blocks = ["0.0.0.0/0"]
}

tags = {
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = local.common_tags
}

resource "aws_iam_role" "automq_byoc_role" {
Expand All @@ -234,10 +236,7 @@ resource "aws_iam_role" "automq_byoc_role" {
]
})

tags = {
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = local.common_tags
}

resource "aws_iam_policy" "automq_byoc_policy" {
Expand All @@ -249,10 +248,7 @@ resource "aws_iam_policy" "automq_byoc_policy" {
automq_ops_bucket = local.automq_ops_bucket
})

tags = {
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = local.common_tags
}

resource "aws_iam_policy" "automq_byoc_k8s_policy" {
Expand All @@ -264,10 +260,7 @@ resource "aws_iam_policy" "automq_byoc_k8s_policy" {
automq_ops_bucket = local.automq_ops_bucket
})

tags = {
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = local.common_tags
}

resource "aws_iam_role_policy_attachment" "automq_byoc_role_attachment_k8s" {
Expand All @@ -284,10 +277,7 @@ resource "aws_iam_instance_profile" "automq_byoc_instance_profile" {
name = "automq-byoc-instance-profile-${var.automq_byoc_env_id}"
role = aws_iam_role.automq_byoc_role.name

tags = {
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = local.common_tags
}

resource "aws_route53_zone" "private_r53" {
Expand All @@ -301,18 +291,12 @@ resource "aws_route53_zone" "private_r53" {
create_before_destroy = true
}

tags = {
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = local.common_tags
}

resource "aws_eip" "web_ip" {
instance = aws_instance.automq_byoc_console.id
tags = {
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = local.common_tags
}

locals {
Expand Down
16 changes: 7 additions & 9 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ resource "aws_instance" "automq_byoc_console" {

key_name = var.automq_byoc_env_console_key_name

tags = {
Name = "automq-byoc-console-${var.automq_byoc_env_id}"
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = merge(
local.common_tags,
{
Name = "automq-byoc-console-${var.automq_byoc_env_id}"
}
)

associate_public_ip_address = true

Expand All @@ -38,10 +39,7 @@ resource "aws_ebs_volume" "data_volume" {
size = 20
type = "gp3"

tags = {
automqVendor = "automq"
automqEnvironmentID = var.automq_byoc_env_id
}
tags = local.common_tags
}

resource "aws_volume_attachment" "data_volume_attachment" {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,9 @@ variable "automq_byoc_env_console_ami" {
type = string
default = ""
}

variable "additional_tags" {
description = "Additional tags to apply to all resources created by this module."
type = map(string)
default = {}
}