# S3 버킷 이름은 고유해야 한다. NICKNAME=masterseo # 코드 파일 생성 cat < backend.tf provider "aws" { region = "ap-northeast-2" } resource "aws_s3_bucket" "mys3bucket" { bucket = "$NICKNAME-t101study-tfstate-week3" } # Enable versioning so you can see the full revision history of your state files resource "aws_s3_bucket_versioning" "mys3bucket_versioning" { bucket = aws_s3_bucket.mys3bucket.id versioning_configuration { status = "Enabled" } } resource "aws_dynamodb_table" "mydynamodbtable" { name = "terraform-locks-week3" billing_mode = "PAY_PER_REQUEST" hash_key = "LockID" attribute { name = "LockID" type = "S" } } output "s3_bucket_arn" { value = aws_s3_bucket.mys3bucket.arn description = "The ARN of the S3 bucket" } output "dynamodb_table_name" { value = aws_dynamodb_table.mydynamodbtable.name description = "The name of the DynamoDB table" } EOT # 배포 terraform init && terraform plan && terraform apply -auto-approve Outputs: dynamodb_table_name = "terraform-locks-week3" s3_bucket_arn = "arn:aws:s3:::masterseo-t101study-tfstate-week3" # 배포 확인 terraform state list [root@ip-172-31-61-209 tf-back]# terraform state list aws_dynamodb_table.mydynamodbtable aws_s3_bucket.mys3bucket aws_s3_bucket_versioning.mys3bucket_versioning aws s3 ls masterseo-t101study-tfstate-week3 aws dynamodb list-tables --output text [root@ip-172-31-61-209 tf-back]# aws dynamodb list-tables --output text TABLENAMES terraform-locks TABLENAMES terraform-locks-week3 # 기존 작업 디렉터리로 이동 cd ..