- Notifications
You must be signed in to change notification settings - Fork328
tf deployment#1416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
levkk wants to merge1 commit intomasterChoose a base branch fromlevkk-add-ec2-tf-deployment
base:master
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
tf deployment#1416
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletionspackages/pgml-rds-proxy/ec2/.gitignore
This file contains hidden or 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 @@ | ||
.terraform | ||
*.lock.hcl | ||
*.tfstate | ||
*.tfstate.backup |
7 changes: 7 additions & 0 deletionspackages/pgml-rds-proxy/ec2/README.md
This file contains hidden or 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,7 @@ | ||
# Terraform configuration for pgml-rds-proxy on EC2 | ||
This is a sample Terraform deployment for running pgml-rds-proxy on EC2. This will spin up an EC2 instance | ||
with a public IP and a working security group & install the community Docker runtime. | ||
Once the instance is running, you can connect to it using the root key and run the pgml-rds-proxy Docker container | ||
with the correct PostgresML `DATABASE_URL`. |
84 changes: 84 additions & 0 deletionspackages/pgml-rds-proxy/ec2/ec2-deployment.tf
This file contains hidden or 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,84 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 5.46" | ||
} | ||
} | ||
required_version = ">= 1.2.0" | ||
} | ||
provider "aws" { | ||
region = "us-west-2" | ||
} | ||
data "aws_ami" "ubuntu" { | ||
most_recent = true | ||
filter { | ||
name = "name" | ||
values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"] | ||
} | ||
filter { | ||
name = "virtualization-type" | ||
values = ["hvm"] | ||
} | ||
owners = ["099720109477"] # Canonical | ||
} | ||
resource "aws_security_group" "pgml-rds-proxy" { | ||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
ipv6_cidr_blocks = ["::/0"] | ||
} | ||
ingress { | ||
from_port = 6432 | ||
to_port = 6432 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
ipv6_cidr_blocks = ["::/0"] | ||
} | ||
ingress { | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
ipv6_cidr_blocks = ["::/0"] | ||
} | ||
} | ||
resource "aws_instance" "pgml-rds-proxy" { | ||
ami = data.aws_ami.ubuntu.id | ||
instance_type = "t3.micro" | ||
key_name = var.root_key | ||
root_block_device { | ||
volume_size = 30 | ||
delete_on_termination = true | ||
} | ||
vpc_security_group_ids = [ | ||
"${aws_security_group.pgml-rds-proxy.id}", | ||
] | ||
associate_public_ip_address = true | ||
user_data = file("${path.module}/user_data.sh") | ||
user_data_replace_on_change = false | ||
tags = { | ||
Name = "pgml-rds-proxy" | ||
} | ||
} | ||
variable "root_key" { | ||
type = string | ||
description = "The name of the SSH Root Key you'd like to assign to this EC2 instance. Make sure it's a key you have access to." | ||
} |
21 changes: 21 additions & 0 deletionspackages/pgml-rds-proxy/ec2/user_data.sh
This file contains hidden or 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,21 @@ | ||
#!/bin/bash | ||
# | ||
# Cloud init script to install Docker on an EC2 instance running Ubuntu 22.04. | ||
# | ||
sudo apt-get update | ||
sudo apt-get install ca-certificates curl | ||
sudo install -m 0755 -d /etc/apt/keyrings | ||
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc | ||
sudo chmod a+r /etc/apt/keyrings/docker.asc | ||
# Add the repository to Apt sources: | ||
echo \ | ||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ | ||
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ | ||
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
sudo apt-get update | ||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | ||
sudo groupadd docker | ||
sudo usermod -aG docker ubuntu |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.