-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modularization for AWS terraform scripts (#650)
* Small fixes for terraform aws - fix hardcode chart version - fix unreachable bastion - adjust tidb-cluster no-wait to avoid scheduled backup pvc blocking - add version check - disable pd node public_ip Signed-off-by: Aylei <rayingecho@gmail.com> * Modularization for AWS terraform scripts Signed-off-by: Aylei <rayingecho@gmail.com> * Refine README of AWS terraform Signed-off-by: Aylei <rayingecho@gmail.com> * Fix bastion ssh Signed-off-by: Aylei <rayingecho@gmail.com> * Rephrase section title Signed-off-by: Aylei <rayingecho@gmail.com> * Update deploy/modules/aws/tidb-operator/README.md Co-Authored-By: Tennix <tennix@users.noreply.github.com> * Address review comments Signed-off-by: Aylei <rayingecho@gmail.com>
- Loading branch information
Showing
41 changed files
with
494 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.terraform/ | ||
credentials/ | ||
terraform.tfstate | ||
terraform.tfstate.backup | ||
.terraform.tfstate.lock.info | ||
kubeconfig_*.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
resource "aws_security_group" "accept_ssh_from_local" { | ||
name = var.bastion_name | ||
description = "Allow SSH access for bastion instance" | ||
vpc_id = var.vpc_id | ||
ingress { | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
cidr_blocks = var.bastion_ingress_cidr | ||
} | ||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
} | ||
|
||
resource "aws_security_group_rule" "enable_ssh_to_workers" { | ||
count = var.enable_ssh_to_workers ? 1 : 0 | ||
security_group_id = var.worker_security_group_id | ||
source_security_group_id = aws_security_group.accept_ssh_from_local.id | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
type = "ingress" | ||
} | ||
|
||
module "ec2" { | ||
source = "terraform-aws-modules/ec2-instance/aws" | ||
|
||
version = "2.3.0" | ||
name = var.bastion_name | ||
instance_count = 1 | ||
ami = data.aws_ami.amazon-linux-2.id | ||
instance_type = var.bastion_instance_type | ||
key_name = var.key_name | ||
associate_public_ip_address = true | ||
monitoring = false | ||
user_data = file("${path.module}/bastion-userdata") | ||
vpc_security_group_ids = [aws_security_group.accept_ssh_from_local.id] | ||
subnet_ids = var.public_subnets | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
data "aws_availability_zones" "available" { | ||
} | ||
|
||
data "aws_ami" "amazon-linux-2" { | ||
most_recent = true | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
output "bastion_ip" { | ||
description = "Bastion IP address" | ||
value = module.ec2.public_ip | ||
} |
Oops, something went wrong.