Virtual Machine running Ubuntu 22.04 or newer
sudo apt update
sudo apt upgrade
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
| # Create a security group | |
| resource "aws_security_group" "web" { | |
| name_prefix = "web-sg" | |
| ingress { | |
| from_port = 22 | |
| to_port = 22 | |
| protocol = "tcp" | |
| cidr_blocks = ["0.0.0.0/0"] | |
| } | 
| region = "us-east-1" | |
| } | |
| resource "aws_instance" "example" { | |
| ami = "ami-0c55b159cbfafe1f0" | |
| instance_type = "t2.micro" | |
| key_name = "existing-key-name" | |
| vpc_security_group_ids = ["existing-security-group-id"] | |
| tags = { | 
| locals { | |
| # Define the path to the current working directory | |
| current_dir = path.cwd | |
| } | |
| resource "aws_s3_bucket" "example_bucket" { | |
| bucket = "example-bucket-${local.current_dir}" | |
| acl = "private" | |
| } | 
| provider "aws" { | |
| region = "us-east-1" | |
| } | |
| locals { | |
| # Define the path to the directory containing your Terraform files | |
| base_dir = path.root | |
| } | |
| resource "aws_s3_bucket" "example_bucket" { | 
| provider "aws" { | |
| region = "us-west-2" | |
| } | |
| resource "aws_s3_bucket" "example_bucket" { | |
| bucket = "example-bucket" | |
| acl = "private" | |
| tags = { | |
| Name = "Example Bucket" | 
| variable "instance_tags" { | |
| type = map(string) | |
| default = { | |
| Name = "my-instance" | |
| } | |
| } | |
| provider "aws" { | |
| region = "us-west-2" | |
| } | 
| variable "security_groups" { | |
| type = list(string) | |
| default = ["default"] | |
| } | |
| provider "aws" { | |
| region = "us-west-2" | |
| } | |
| resource "aws_instance" "example" { | 
| variable "instance_name" { | |
| type = string | |
| default = "my-instance" | |
| } | |
| provider "aws" { | |
| region = "us-west-2" | |
| } | |
| resource "aws_instance" "example" { | 
| variable "instance_count" { | |
| type = number | |
| default = 1 | |
| } | |
| provider "aws" { | |
| region = "us-west-2" | |
| } | |
| resource "aws_instance" "example" { |