automated ec2 setup and build
This commit is contained in:
parent
bf8b932cdc
commit
1afbc41599
5 changed files with 103 additions and 49 deletions
|
|
@ -66,6 +66,12 @@ variable "domain" {
|
|||
default = "everytab.site"
|
||||
}
|
||||
|
||||
variable "repo_url" {
|
||||
description = "Git repo URL for the pipeline code (public)"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
# --- Data sources ---
|
||||
|
||||
data "aws_ami" "al2023" {
|
||||
|
|
@ -338,6 +344,7 @@ resource "aws_instance" "db" {
|
|||
key_name = aws_key_pair.ec2[0].key_name
|
||||
vpc_security_group_ids = [aws_security_group.db[0].id]
|
||||
subnet_id = var.subnet_ids[0]
|
||||
user_data = file("${path.module}/db-setup.sh")
|
||||
|
||||
tags = {
|
||||
Name = "everytab-db"
|
||||
|
|
@ -354,6 +361,10 @@ resource "aws_instance" "main" {
|
|||
vpc_security_group_ids = [aws_security_group.ec2[0].id]
|
||||
subnet_id = var.subnet_ids[0]
|
||||
iam_instance_profile = aws_iam_instance_profile.ec2[0].name
|
||||
user_data = templatefile("${path.module}/ec2-userdata.sh", {
|
||||
db_private_ip = aws_instance.db[0].private_ip
|
||||
repo_url = var.repo_url
|
||||
})
|
||||
|
||||
root_block_device {
|
||||
volume_size = 1000
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue