AWS DevOps - TerraForm 생성
* 테라폼 (Terraform)
- 아마존과 별개의 회사
- 클라우드 컨설팅 브로커(?)회사
$ sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl
$ curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
$ sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
$ sudo apt-get update && sudo apt-get install terraform
$ terraform -install-autocomplete
$ mkdir terraform-docker-demo && cd $_
$ vi main.tf
$ export AWS_ACCESS_KEY_ID='AKIASQIMVHNHQFD4YYVE'
$ export AWS_SECRET_ACCESS_KEY='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'
$ terraform init
$ terraform fmt
$ terraform validate
$ terraform apply
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.27"
}
}
required_version = ">= 0.14.9"
}
provider "aws" {
profile = "default"
region = "eu-west-1"
}
resource "aws_instance" "app_server" {
ami = "ami-0d71ea30463e0ff8d"
instance_type = "t2.micro"
key_name = "bys_west_1"
security_groups = [
"Web_Server",
]
tags = {
Name = "bys"
}
resource "aws_security_group" "web" {
name = "Web_Server" // 보안 그룹 이름으로 들어감
description = "For web server & SSH" // 설명 추가
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["내ip/32"]
}
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
}
'클라우드 > AWS' 카테고리의 다른 글
[AWS 프로젝트] EC2 생성 및 bastion host로 접속 (0) | 2022.08.20 |
---|---|
[ 클라우드 ] 10일차 ( AWS DevOps - CodePipeline, SNS, Lambda) (0) | 2022.06.23 |
[ 클라우드 ] 9일차 ( AWS CloudFront, Lambda 이론) (0) | 2022.06.23 |
[ 클라우드 ] 9일차 ( AWS DevOps - BeanStalk ) (0) | 2022.06.23 |
[ 클라우드 ] 8일차 ( AWS DevOps - CloudFormation ) (0) | 2022.06.23 |