Skip to content

Commit

Permalink
Merge pull request #7 from AutoMQ/zhaoxi-0817
Browse files Browse the repository at this point in the history
feat: Disable the bucket creation switch and handle it by default.
  • Loading branch information
Kris20030907 authored Aug 17, 2024
2 parents 56c5247 + cf1eec3 commit 2cebeee
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 73 deletions.
38 changes: 16 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,32 +110,26 @@ No requirements.
| <a name="input_automq_byoc_env_console_cidr"></a> [automq\_byoc\_env\_console\_cidr](#input\_automq\_byoc\_env\_console\_cidr) | Set CIDR block to restrict the source IP address range for accessing the AutoMQ environment console. If not set, the default is 0.0.0.0/0. | `string` | `"0.0.0.0/0"` | no |
| <a name="input_automq_byoc_vpc_id"></a> [automq\_byoc\_vpc\_id](#input\_automq\_byoc\_vpc\_id) | The ID of the VPC | `string` | n/a | no |
| <a name="input_cloud_provider_region"></a> [cloud\_provider\_region](#input\_cloud\_provider\_region) | Set the cloud provider's region. AutoMQ will deploy to this region. | `string` | n/a | yes |
| <a name="input_create_automq_byoc_data_bucket"></a> [create\_automq\_byoc\_data\_bucket](#input\_create\_automq\_byoc\_data\_bucket) | This parameter controls whether to create a new bucket. If it is a POC scenario or there is no available bucket, set it to true. If there is already a suitable bucket, set it to false. | `bool` | `true` | no |
| <a name="input_create_automq_byoc_ops_bucket"></a> [create\_automq\_byoc\_ops\_bucket](#input\_create\_automq\_byoc\_ops\_bucket) | This parameter controls whether to create a new bucket. If it is a POC scenario or there is no available bucket, set it to true. If there is already a suitable bucket, set it to false. | `bool` | `true` | no |
| <a name="input_create_new_vpc"></a> [create\_new\_vpc](#input\_create\_new\_vpc) | This setting determines whether to create a new VPC. If set to true, a new VPC spanning three availability zones will be automatically created, which is recommended only for POC scenarios. For production scenario using AutoMQ, you should provide the VPC where the current Kafka application resides and check the current VPC against the requirements specified in the documentation. | `bool` | `true` | no |
| <a name="input_specific_data_bucket_name"></a> [specific\_data\_bucket\_name](#input\_specific\_data\_bucket\_name) | Set up a new object storage bucket that will be used to store message data generated by applications. The message data Bucket must be separate from the Ops Bucket. | `string` | `"automq-data"` | no |
| <a name="input_specific_ops_bucket_name"></a> [specific\_ops\_bucket\_name](#input\_specific\_ops\_bucket\_name) | Set up a new object storage bucket that will be used to store AutoMQ system logs and metrics data for system monitoring and alerts. This Bucket does not contain any application business data. The Ops Bucket must be separate from the message data Bucket. | `string` | `"automq-ops"` | no |
| <a name="input_specified_ami_by_marketplace"></a> [specified\_ami\_by\_marketplace](#input\_specified\_ami\_by\_marketplace) | Specifies the switch to obtain ami id from the cloud market. If true, it means to obtain the specified version of ami id through the cloud market. Otherwise, it needs to be specified manually. | `bool` | `true` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_automq_byoc_data_bucket_arn"></a> [automq\_byoc\_data\_bucket\_arn](#output\_automq\_byoc\_data\_bucket\_arn) | Data storage bucket arn. |
| <a name="output_automq_byoc_data_bucket_name"></a> [automq\_byoc\_data\_bucket\_name](#output\_automq\_byoc\_data\_bucket\_name) | The object storage bucket for that used to store message data generated by applications. The message data Bucket must be separate from the Ops Bucket. |
| <a name="output_automq_byoc_env_console_ami"></a> [automq\_byoc\_env\_console\_ami](#output\_automq\_byoc\_env\_console\_ami) | Mirror ami id of AutoMQ BYOC Console. |
| <a name="output_automq_byoc_env_console_cidr"></a> [automq\_byoc\_env\_console\_cidr](#output\_automq\_byoc\_env\_console\_cidr) | AutoMQ BYOC security group CIDR. |
| <a name="output_automq_byoc_env_console_ec2_instance_ip"></a> [automq\_byoc\_env\_console\_ec2\_instance\_ip](#output\_automq\_byoc\_env\_console\_ec2\_instance\_ip) | The instance IP of the deployed AutoMQ BYOC control panel. You can access the service through this IP. |
| Name | Description |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|
| <a name="output_automq_byoc_data_bucket_name"></a> [automq\_byoc\_data\_bucket\_name](#output\_automq\_byoc\_data\_bucket\_name) | The object storage bucket for that used to store message data generated by applications. The message data Bucket must be separate from the Ops Bucket. |
| <a name="output_automq_byoc_env_console_ami"></a> [automq\_byoc\_env\_console\_ami](#output\_automq\_byoc\_env\_console\_ami) | Mirror ami id of AutoMQ BYOC Console. |
| <a name="output_automq_byoc_env_console_cidr"></a> [automq\_byoc\_env\_console\_cidr](#output\_automq\_byoc\_env\_console\_cidr) | AutoMQ BYOC security group CIDR. |
| <a name="output_automq_byoc_env_console_ec2_instance_ip"></a> [automq\_byoc\_env\_console\_ec2\_instance\_ip](#output\_automq\_byoc\_env\_console\_ec2\_instance\_ip) | The instance IP of the deployed AutoMQ BYOC control panel. You can access the service through this IP. |
| <a name="output_automq_byoc_env_console_public_subnet_id"></a> [automq\_byoc\_env\_console\_public\_subnet\_id](#output\_automq\_byoc\_env\_console\_public\_subnet\_id) | AutoMQ WebUI is deployed under this subnet. |
| <a name="output_automq_byoc_env_id"></a> [automq\_byoc\_env\_id](#output\_automq\_byoc\_env\_id) | This parameter is used to create resources within the environment. Additionally, all cloud resource names will incorporate this parameter as part of their names.This parameter supports only numbers, uppercase and lowercase English letters, and hyphens. It must start with a letter and is limited to a length of 32 characters. |
| <a name="output_automq_byoc_endpoint"></a> [automq\_byoc\_env\_webui\_address](#output\_automq\_byoc\_env\_webui\_address) | Address accessed by AutoMQ BYOC service |
| <a name="output_automq_byoc_instance_id"></a> [automq\_byoc\_instance\_id](#output\_automq\_byoc\_instance\_id) | AutoMQ BYOC Console instance ID. |
| <a name="output_automq_byoc_instance_profile_arn"></a> [automq\_byoc\_instance\_profile\_arn](#output\_automq\_byoc\_instance\_profile\_arn) | Instance configuration file ARN |
| <a name="output_automq_byoc_ops_bucket_arn"></a> [automq\_byoc\_ops\_bucket\_arn](#output\_automq\_byoc\_ops\_bucket\_arn) | Ops storage bucket arn. |
| <a name="output_automq_byoc_ops_bucket_name"></a> [automq\_byoc\_ops\_bucket\_name](#output\_automq\_byoc\_ops\_bucket\_name) | The object storage bucket for that used to store AutoMQ system logs and metrics data for system monitoring and alerts. This Bucket does not contain any application business data. The Ops Bucket must be separate from the message data Bucket. |
| <a name="output_automq_byoc_policy_arn"></a> [automq\_byoc\_policy\_arn](#output\_automq\_byoc\_policy\_arn) | AutoMQ BYOC is bound to a custom policy on the role arn. |
| <a name="output_automq_byoc_role_arn"></a> [automq\_byoc\_role\_arn](#output\_automq\_byoc\_role\_arn) | AutoMQ BYOC is bound to the role arn of the Console. |
| <a name="output_automq_byoc_security_group_name"></a> [automq\_byoc\_security\_group\_name](#output\_automq\_byoc\_security\_group\_name) | Security group bound to the AutoMQ BYOC service. |
| <a name="output_automq_byoc_vpc_id"></a> [automq\_byoc\_vpc\_id](#output\_automq\_byoc\_vpc\_id) | AutoMQ BYOC is deployed in this VPC. |
| <a name="output_automq_byoc_vpc_route53_zone_id"></a> [automq\_byoc\_vpc\_route53\_zone\_id](#output\_automq\_byoc\_vpc\_route53\_zone\_id) | Route53 bound to the VPC. |
| <a name="output_automq_byoc_env_id"></a> [automq\_byoc\_env\_id](#output\_automq\_byoc\_env\_id) | This parameter is used to create resources within the environment. Additionally, all cloud resource names will incorporate this parameter as part of their names.This parameter supports only numbers, uppercase and lowercase English letters, and hyphens. It must start with a letter and is limited to a length of 32 characters. |
| <a name="output_automq_byoc_endpoint"></a> [automq\_byoc\_endpoint](#output\_automq\_byoc\_endpoint) | Address accessed by AutoMQ BYOC service |
| <a name="output_automq_byoc_instance_id"></a> [automq\_byoc\_instance\_id](#output\_automq\_byoc\_instance\_id) | AutoMQ BYOC Console instance ID. |
| <a name="output_automq_byoc_instance_profile_arn"></a> [automq\_byoc\_instance\_profile\_arn](#output\_automq\_byoc\_instance\_profile\_arn) | Instance configuration file ARN |
| <a name="output_automq_byoc_ops_bucket_name"></a> [automq\_byoc\_ops\_bucket\_name](#output\_automq\_byoc\_ops\_bucket\_name) | The object storage bucket for that used to store AutoMQ system logs and metrics data for system monitoring and alerts. This Bucket does not contain any application business data. The Ops Bucket must be separate from the message data Bucket. |
| <a name="output_automq_byoc_policy_arn"></a> [automq\_byoc\_policy\_arn](#output\_automq\_byoc\_policy\_arn) | AutoMQ BYOC is bound to a custom policy on the role arn. |
| <a name="output_automq_byoc_role_arn"></a> [automq\_byoc\_role\_arn](#output\_automq\_byoc\_role\_arn) | AutoMQ BYOC is bound to the role arn of the Console. |
| <a name="output_automq_byoc_security_group_name"></a> [automq\_byoc\_security\_group\_name](#output\_automq\_byoc\_security\_group\_name) | Security group bound to the AutoMQ BYOC service. |
| <a name="output_automq_byoc_vpc_id"></a> [automq\_byoc\_vpc\_id](#output\_automq\_byoc\_vpc\_id) | AutoMQ BYOC is deployed in this VPC. |
| <a name="output_automq_byoc_vpc_route53_zone_id"></a> [automq\_byoc\_vpc\_route53\_zone\_id](#output\_automq\_byoc\_vpc\_route53\_zone\_id) | Route53 bound to the VPC. |
<!-- END_TF_DOCS -->
24 changes: 9 additions & 15 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ module "automq_byoc_data_bucket_name" {
source = "terraform-aws-modules/s3-bucket/aws"
version = "4.1.2"

# Switch whether to create a bucket. If it is true, it will be created. If it is false, it will use the name entered by the user. If the name is empty, it will default to automq-data.
create_bucket = var.create_automq_byoc_data_bucket
bucket = var.create_automq_byoc_data_bucket ? (
var.specific_data_bucket_name == "" ? "automq-data-${var.automq_byoc_env_id}" : var.specific_data_bucket_name
) : (
var.automq_byoc_data_bucket_name == "" ? "automq-data-${var.automq_byoc_env_id}" : var.automq_byoc_data_bucket_name
)
# If you don't specify a data-bucket, it will be created, otherwise the available bucket provided will be used
create_bucket = var.automq_byoc_data_bucket_name == "" ? true : false
bucket = "automq-data-${var.automq_byoc_env_id}"
force_destroy = true
}

Expand All @@ -22,12 +18,8 @@ module "automq_byoc_ops_bucket_name" {
source = "terraform-aws-modules/s3-bucket/aws"
version = "4.1.2"

create_bucket = var.create_automq_byoc_ops_bucket
bucket = var.create_automq_byoc_ops_bucket ? (
var.specific_ops_bucket_name == "" ? "automq-ops-${var.automq_byoc_env_id}" : var.specific_ops_bucket_name
) : (
var.automq_byoc_ops_bucket_name == "" ? "automq-ops-${var.automq_byoc_env_id}" : var.automq_byoc_ops_bucket_name
)
create_bucket = var.automq_byoc_ops_bucket_name == "" ? true : false
bucket = "automq-ops-${var.automq_byoc_env_id}"
force_destroy = true
}

Expand Down Expand Up @@ -124,6 +116,8 @@ resource "aws_vpc_endpoint" "s3" {
locals {
automq_byoc_vpc_id = var.create_new_vpc ? module.automq_byoc_vpc[0].vpc_id : var.automq_byoc_vpc_id
automq_byoc_env_console_public_subnet_id = var.create_new_vpc ? element(module.automq_byoc_vpc[0].public_subnets, 0) : var.automq_byoc_env_console_public_subnet_id
automq_data_bucket = var.automq_byoc_data_bucket_name == "" ? module.automq_byoc_data_bucket_name.s3_bucket_id : "${var.automq_byoc_data_bucket_name}-${var.automq_byoc_env_id}"
automq_ops_bucket = var.automq_byoc_ops_bucket_name == "" ? module.automq_byoc_ops_bucket_name.s3_bucket_id : "${var.automq_byoc_ops_bucket_name}-${var.automq_byoc_env_id}"
}

module "automq_byoc" {
Expand All @@ -132,8 +126,8 @@ module "automq_byoc" {
cloud_provider_region = var.cloud_provider_region
automq_byoc_vpc_id = local.automq_byoc_vpc_id
automq_byoc_env_console_public_subnet_id = local.automq_byoc_env_console_public_subnet_id
automq_byoc_data_bucket_name = module.automq_byoc_data_bucket_name.s3_bucket_id
automq_byoc_ops_bucket_name = module.automq_byoc_ops_bucket_name.s3_bucket_id
automq_byoc_data_bucket_name = local.automq_data_bucket
automq_byoc_ops_bucket_name = local.automq_ops_bucket
automq_byoc_env_id = var.automq_byoc_env_id
automq_byoc_ec2_instance_type = var.automq_byoc_ec2_instance_type
automq_byoc_env_version = var.automq_byoc_env_version
Expand Down
8 changes: 8 additions & 0 deletions modules/aws-console-module/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ output "automq_byoc_security_group_name" {
value = aws_security_group.allow_all.name
}

output "automq_byoc_data_bucket_name" {
value = var.automq_byoc_data_bucket_name
}

output "automq_byoc_ops_bucket_name" {
value = var.automq_byoc_ops_bucket_name
}

output "automq_byoc_role_arn" {
value = aws_iam_role.automq_byoc_role.arn
}
Expand Down
14 changes: 2 additions & 12 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,12 @@ output "automq_byoc_endpoint" {

output "automq_byoc_data_bucket_name" {
description = "The object storage bucket for that used to store message data generated by applications. The message data Bucket must be separate from the Ops Bucket."
value = module.automq_byoc_data_bucket_name.s3_bucket_id
}

output "automq_byoc_data_bucket_arn" {
description = "Data storage bucket arn."
value = module.automq_byoc_data_bucket_name.s3_bucket_arn
value = module.automq_byoc.automq_byoc_data_bucket_name
}

output "automq_byoc_ops_bucket_name" {
description = "The object storage bucket for that used to store AutoMQ system logs and metrics data for system monitoring and alerts. This Bucket does not contain any application business data. The Ops Bucket must be separate from the message data Bucket."
value = module.automq_byoc_ops_bucket_name.s3_bucket_id
}

output "automq_byoc_ops_bucket_arn" {
description = "Ops storage bucket arn."
value = module.automq_byoc_ops_bucket_name.s3_bucket_arn
value = module.automq_byoc.automq_byoc_ops_bucket_name
}

output "automq_byoc_role_arn" {
Expand Down
24 changes: 0 additions & 24 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,6 @@ variable "automq_byoc_ops_bucket_name" {
default = ""
}

variable "create_automq_byoc_data_bucket" {
description = "This parameter controls whether to create a new bucket. If it is a POC scenario or there is no available bucket, set it to true. If there is already a suitable bucket, set it to false."
type = bool
default = true
}

variable "create_automq_byoc_ops_bucket" {
description = "This parameter controls whether to create a new bucket. If it is a POC scenario or there is no available bucket, set it to true. If there is already a suitable bucket, set it to false."
type = bool
default = true
}

variable "specific_data_bucket_name" {
description = "Set up a new object storage bucket that will be used to store message data generated by applications. The message data Bucket must be separate from the Ops Bucket."
type = string
default = ""
}

variable "specific_ops_bucket_name" {
description = "Set up a new object storage bucket that will be used to store AutoMQ system logs and metrics data for system monitoring and alerts. This Bucket does not contain any application business data. The Ops Bucket must be separate from the message data Bucket."
type = string
default = ""
}

variable "specified_ami_by_marketplace" {
description = "Specifies the switch to obtain ami id from the cloud market. If true, it means to obtain the specified version of ami id through the cloud market. Otherwise, it needs to be specified manually."
type = bool
Expand Down

0 comments on commit 2cebeee

Please sign in to comment.