2022/05

    [Terraform] terraform init Error 해결

    terraform init을 할때 backend로 설정한 s3 버킷이 없거나 버킷명이 잘못 되었을 경우 아래와 같은 메시지가 발생합니다. Initializing the backend... Successfully configured the backend "s3"! Terraform will automatically use this backend unless the backend configuration changes. Error refreshing state: BucketRegionError: incorrect region, the bucket is not in 'ap-northeast-2' region at endpoint '' status code: 301, request ..

    [Terraform] AWS S3 Bucket Policy 규칙 추가 방법

    Intro 오늘은 테라폼을 이용하여 S3 Bucket policy 규칙을 추가해보도록 하겠습니다. S3 Bucket policy는 json 형태로 되어있으며 이는 IAM policy와 매우 유사하기 때문에 향 후 IAM policy에 규칙을 추가하는데에도 동일하게 적용이 가능합니다. 참고로 아래 URL에서와 같이 cloudwatch logs에 데이터를 s3 bucket에 넣기 위해 필요한 policy를 추가 하는 예제로 설명드리겠습니다. https://docs.aws.amazon.com/ko_kr/AmazonCloudWatch/latest/logs/S3ExportTasksConsole.html Bucket policy 추가 하는 2가지 방법 테라폼 소스로 Bucket policy를 추가하는 방법은 2가지..