finalized automated build for web
This commit is contained in:
@@ -44,7 +44,15 @@
|
||||
"sudo yum -y install dos2unix",
|
||||
"wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash",
|
||||
". ~/.nvm/nvm.sh",
|
||||
"nvm install 12"
|
||||
"nvm install 12",
|
||||
"n=$(which node)",
|
||||
"n=${n%/bin/node}",
|
||||
"sudo chmod -R 755 $n/bin/*",
|
||||
"sudo cp -r $n/{bin,lib,share} /usr/local",
|
||||
"n=$(which npm)",
|
||||
"n=${n%/bin/npm}",
|
||||
"sudo chmod -R 755 $n/bin/*",
|
||||
"sudo cp -r $n/{bin,lib,share} /usr/local"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -59,6 +67,7 @@
|
||||
"sudo dos2unix /tmp/platform-uploads/opt/web-init/web-init.sh",
|
||||
"sudo cp -rf /tmp/platform-uploads/etc/* /etc/",
|
||||
"sudo cp -rf /tmp/platform-uploads/opt/* /opt/",
|
||||
"sudo chmod 755 /opt/web-init/web-init.sh",
|
||||
"sudo systemctl enable web-init",
|
||||
"sudo rm -rf /tmp/platform-uploads"
|
||||
]
|
||||
|
||||
@@ -4,6 +4,7 @@ Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
User=ec2-user
|
||||
ExecStart=/opt/web-init/web-init.sh
|
||||
Restart=always
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
aws s3 cp s3://catherine-fc-infra/build.tar.gz .
|
||||
tar zxf build.tar.gz
|
||||
rm build.tar.gz
|
||||
cd build
|
||||
rm -rf /tmp/build.tar.gz
|
||||
rm -rf /tmp/build
|
||||
aws s3 cp s3://catherine-fc-infra/build.tar.gz /tmp/build.tar.gz
|
||||
tar -C /tmp -zxvf /tmp/build.tar.gz
|
||||
cd /tmp/build/
|
||||
npm i
|
||||
node server/index.js
|
||||
@@ -35,7 +35,7 @@ variable "vpc_id" {
|
||||
variable "internal_subnet_ids" {
|
||||
type = map(list(string))
|
||||
default = {
|
||||
prod = [ "subnet-0d0fdf45", "subnet-4dcecc16", "subnet-4dcecc16" ]
|
||||
prod = [ "subnet-0d0fdf45", "subnet-4dcecc16", "subnet-803fe4ab" ]
|
||||
}
|
||||
}
|
||||
variable "key_name" {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
resource "aws_autoscaling_group" "es_asg" {
|
||||
resource "aws_autoscaling_group" "catherine_fc_asg" {
|
||||
name = "${var.basename}-${terraform.workspace}"
|
||||
|
||||
availability_zones = ["ap-northeast-1a", "ap-northeast-1c", "ap-northeast-1d"]
|
||||
@@ -9,7 +9,7 @@ resource "aws_autoscaling_group" "es_asg" {
|
||||
min_size = var.asg_caps.min
|
||||
|
||||
launch_configuration = aws_launch_configuration.catherine_fc_conf.name
|
||||
|
||||
target_group_arns = [aws_lb_target_group.target_group_web.id]
|
||||
tags = concat(var.asg_tags, [
|
||||
{
|
||||
key = "STAGE_ENVIRONMENT",
|
||||
|
||||
@@ -5,7 +5,7 @@ data "aws_ami" "catherine_fc_ami" {
|
||||
|
||||
filter {
|
||||
name = "name"
|
||||
values = [ "catherine-fc" ]
|
||||
values = [ "catherine-fc-*" ]
|
||||
}
|
||||
|
||||
owners = [ "353699021357" ]
|
||||
|
||||
@@ -90,8 +90,3 @@ resource "aws_iam_role_policy" "catherine_fc_s3" {
|
||||
}
|
||||
EOF5
|
||||
}
|
||||
|
||||
resource "aws_iam_role_policy_attachment" "GOV_ssm_basic" {
|
||||
role = aws_iam_role.instance.id
|
||||
policy_arn = "arn:aws:iam::${data.aws_caller_identity.self.account_id}:policy/GOV_ssm_basic"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ resource "aws_launch_configuration" "catherine_fc_conf" {
|
||||
instance_type = var.ec2_instance_type
|
||||
iam_instance_profile = aws_iam_instance_profile.catherine_fc_profile.name
|
||||
security_groups = [
|
||||
aws_security_group.catherine_fc_ec2_sg.id
|
||||
aws_security_group.catherine_fc_asg_sg.id
|
||||
]
|
||||
user_data = <<-EOF
|
||||
#!/bin/bash
|
||||
|
||||
@@ -2,15 +2,15 @@ resource "aws_lb" "catherine_fc_load_balancer" {
|
||||
name = "catherine-fc-lb"
|
||||
internal = false
|
||||
load_balancer_type = "application"
|
||||
security_groups = [aws_security_group.catherine_fc_lb_sg]
|
||||
subnets = [var.internal_subnet_ids]
|
||||
security_groups = [aws_security_group.catherine_fc_lb_sg.id]
|
||||
subnets = var.internal_subnet_ids
|
||||
|
||||
enable_deletion_protection = true
|
||||
|
||||
tags = var.tags
|
||||
}
|
||||
resource "aws_lb_listener" "front_end" {
|
||||
load_balancer_arn = aws_lb.front_end.arn
|
||||
resource "aws_lb_listener" "catherine_fc_load_balancer_listener" {
|
||||
load_balancer_arn = aws_lb.catherine_fc_load_balancer.arn
|
||||
port = "443"
|
||||
protocol = "HTTPS"
|
||||
ssl_policy = "ELBSecurityPolicy-TLS-1-2-Ext-2018-06"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
output "asg_arn" {
|
||||
value = aws_autoscaling_group.es_asg.arn
|
||||
value = aws_autoscaling_group.catherine_fc_asg.arn
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
resource "aws_security_group" "catherine_fc_asg_sg" {
|
||||
name = "catherine-fc-asg-sg"
|
||||
description = "catherine fc security group"
|
||||
vpc_id = var.vpc_id
|
||||
tags = var.tags
|
||||
@@ -27,6 +28,7 @@ resource "aws_security_group_rule" "catherine_fc_asg_sg_allow_egress" {
|
||||
}
|
||||
|
||||
resource "aws_security_group" "catherine_fc_lb_sg" {
|
||||
name = "catherine-fc-alb-sg"
|
||||
description = "catherine fc security group for load balancer"
|
||||
vpc_id = var.vpc_id
|
||||
tags = var.tags
|
||||
@@ -43,7 +45,7 @@ resource "aws_security_group_rule" "catherine_fc_alb_sg_ingress" {
|
||||
security_group_id = aws_security_group.catherine_fc_lb_sg.id
|
||||
}
|
||||
|
||||
resource "aws_security_group_rule" "catherine_fc_asg_sg_allow_egress" {
|
||||
resource "aws_security_group_rule" "catherine_fc_alb_sg_allow_egress" {
|
||||
description = "allow all"
|
||||
type = "egress"
|
||||
protocol = "all"
|
||||
|
||||
@@ -2,5 +2,5 @@ resource "aws_lb_target_group" "target_group_web" {
|
||||
name = "catherine-fc-tg"
|
||||
port = 8080
|
||||
protocol = "HTTP"
|
||||
vpc_id = aws_vpc.main.id
|
||||
vpc_id = var.vpc_id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user