전체 글 535

[30] Github -> Ansible

[1]Terraform -> 서버를 만들기까지Ansible -> 서버 만든 뒤 셋팅GitHub Actions -> terraform apply / ansible-playbook 실행 - [2]Github Actionsgit push ↓GitHub Actions 실행 ↓Terraform apply ↓Inventory 자동 생성 ↓Ansible 실행 ↓EC2 + nginx 완성 - [3]구성aws-lab/├─ terraform/│ ├─ main.tf│ └─ outputs.tf├─ ansible/│ ├─ playbooks/nginx.yml│ ├─ inventory.ini (자동 생성)│ └─ ansible.cfg├─ .github/│ └─ workflows/│ └─ deploy.ym..

[29] Ansible

[0]설치WSL로 한다 cat /etc/os-releasednf install -y epel-releasednf install -y ansibleansible --version - [1]패키지 확인python --versionssh -V - [2]pem key 체크ls -l ~/.ssh *대표 키 종류 id_rsaid_rsa.pubmykey.pemchmod 600 ~/.ssh/mykey.pem - [3]키 생성 - [4]WSL에서 key 복사[user@DESKTOP-27POUJI ~]$ cp /mnt/c/terraform/.ssh/mykey.pem ~/.ssh/[user@DESKTOP-27POUJI ~]$ chmod 600 ~/.ssh/mykey.pem[user@DESKTOP-27POUJI ~]$ ssh..

[28] 리소스 참조

terraform main backend에서 bootstrap s3와 ddb를 참조 해야하잖아? 둘 다 aws에 생성된 hex 값이 아닌 내 리소스 이름을 넣어주면 되지? -------------------------------------- resource "aws_s3_bucket" "tf_state" { bucket = "my-tf-state-bucket-${random_id.suffix.hex}" force_destroy = false tags = { Name = "tf-state" } } # [2] DynamoDB resource "aws_dynamodb_table" "tf_lock" { name = "my_tf_lock" billi..

[27] backend 실제 구현

[0]infra/├── .gitignore├── README.md├── bootstrap/│ ├── main.tf│ ├── .terraform/│ └── .terraform.lock.hcl├── main/│ ├── backend.tf│ ├── main.tf│ ├── variables.tf│ ├── terraform.tfvars│ ├── outputs.tf│ ├── .terraform/│ └── .terraform.lock.hcl개요boostrap에서는 BE를 s3로 걸어버리면 terraform init 단계에서 Bucket이 없어서 막힘 1. bootstrap (로컬 state) 로 실행-> S3 + DDB 생성-> tfstate가 로컬에 한번 생김 2. main (S..

[26] tfstate 개념

[0]terraform.tfstate?Terraform이 알고 있는 현실 인프라의 스냅샷 - [1]tfstate안에 들어 있는 정보1. 실제 생성된 리소스 정보-> Terraform 코드에는 없고, apply 이후에만 알 수 있는 현실값 (pointer)👉 AWS 콘솔에서만 알 수 있는 값들EC2 instance IDENI IDSubnet IDSecurity Group ID실제 할당된 IPRDS endpointALB ARN"resources": [ { "type": "aws_instance", "name": "web", "instances": [ { "attributes": { "id": "i-0abc1234", "private_i..

[24] IAMROLE 추가

[0]플로우1. IAM Role (신뢰정책 : ec2.amazonaws.com)2. Role에 S3 접근 정책 부여 (READONLY or 특정 Bucket 전용 정책)3. Instance Profile 생성 후 EC2에 연결4. EC2의 메타데이터 서비스(IMDS)를 통해 임시 자격증명 발급-> aws s3 ls 가능 - [1]해석- EC2는 아무 키도 없고- IAM Role도 키를 직접 주는 것은 아니며- AWS가 IMDS를 통해 "짧은 수명의 임시 자격증명" 을 자동 발급- SDK / CLI 가 그걸 읽어서 aws s3 ls가 된다 - [2]IAM Role : 이 EC2는 이런 권한을 가질 수 있다는 정의서Trust Policy : 이 Role을 누가 사용할 수 있는지Permission Policy..