charsyam / the_red_infra

the red infra
Apache License 2.0
39 stars 25 forks source link

terraform apply "output"오류 #5

Open GunWoo-Park opened 2 years ago

GunWoo-Park commented 2 years ago

image

terraform apply "output" 명령어를 치면 스팟 인스턴스를 호출 못하고 있습니다

charsyam commented 2 years ago

@GunWoo-Park 에러를 보시면 현재 allow_the_red 라는 security group이 이미 존재한다고 되어있습니다. 해당 security group을 삭제하고 다시 terraform plan, terraform init을 해보시면 될듯합니다.

GunWoo-Park commented 2 years ago

보안 그룹 삭제가 안되고 있는데 어떻게 하나요?

charsyam commented 2 years ago

1] terraform destroy 를 이용하시는 방법이 있고, 해당 방법으로 잘 지워지지 않는다면... 2] aws console 로 접근하셔서 메뉴 ec2 왼쪽 서브 메뉴에 보면 security group 이 보이고, 거기서 해당 시큐리티 그룹을 선택하시고 삭제하시면 됩니다.

GunWoo-Park commented 2 years ago

1] 은 공급자 자격 증명 유효성 검사 오류?가 나오네요 image 2] 는 인바운드 규칙 삭제하고 보안 그룹 삭제하려고 시도하니 다음과 같은 메세지가 뜨면서 삭제가 안됩니다.. image

charsyam commented 2 years ago

2] 로 보실때 이름이 allow_the_red 로 설정된 security 그름이 삭제가 안되는 걸까요? 위에 화면에는 default 그룹을 삭제하려고 시도하시는 걸로 보입니다. :)

GunWoo-Park commented 2 years ago

allow_the_red 로 설정된 security 그룹은 처음부터 없었어요... 만든적도 없구요, the_red라는 ami 유저만 만들었습니다.

charsyam commented 2 years ago

Security Group 목록을 캡쳐해서 올려주실 수 있으실까요?

GunWoo-Park commented 2 years ago

네 여기 있습니다 image

charsyam commented 2 years ago

감사합니다 그런데 혹시 해당 계정의 AWS 액세스 키를 사용하신게 맞을까요? 에러는 중복에러인데 저기에 현재 데이터가 없으면 흐음

GunWoo-Park commented 2 years ago

맞는거 같습니다.. IAM 사용자는 아래로 하였습니다.

참고로 전에 동일한 사용자명으로 만들었다가 시크릿키 인증이 안되서, 지우고 다시 만들었습니다.

image

charsyam commented 2 years ago

혹시 사용하시는 PC의 시간이 맞는지 한번 체크해보시겠어요? https://mystria.github.io/archivers/fail-case-time-error-ntp-settings

GunWoo-Park commented 2 years ago

시간이 맞지 않아서 서울/뉴욕으로 맞춰서 apply 진행해봤는데 안되네요...

charsyam commented 2 years ago

혹시 관련 에러메시지를 모두 붙여주실 수 있으실까요? 캡쳐 말고 텍스트를 @GunWoo-Park

GunWoo-Park commented 2 years ago

1. │ Error: error configuring Terraform AWS Provider: error validating provider credentials: error calling sts:GetCallerIdentity: SignatureDoesNotMatch: Signature expired: 20220325T152559Z is now earlier than 20220403T060022Z (20220403T061522Z - 15 min.) │ status code: 403, request id: 699c797d-7b85-4c55-b406-c034db955c4d │ │ with provider["registry.terraform.io/hashicorp/aws"], │ on provider.tf line 12, in provider "aws": │ 12: provider "aws" { 시간을 맞춰주니 2와 같은 메세지가 나옴. 2. st-2$ terraform apply "output" ╷ │ Error: Saved plan is stale │ │ The given plan file can no longer be applied because the state was changed │ by another operation after the plan was created. terraform plan -out "output" 을 다시 실행시켜주니 3과 같은 메세지가 나옴

3. st-2$ terraform apply "output" aws_security_group.allow_the_red: Creating... ╷ │ Error: error creating Security Group (allow_the_red): InvalidGroup.Duplicate: The security group 'allow_the_red' already exists for VPC 'vpc-068396475888dfa81' │ status code: 400, request id: 6280c323-b383-484b-a7f7-7da1bb889b02 │ │ with aws_security_group.allow_the_red, │ on sg.tf line 1, in resource "aws_security_group" "allow_the_red": │ 1: resource "aws_security_group" "allow_the_red" { │

여전히 진행이 안되고 있네요... 참고로 allow_the_red를 만든적은 없고, 강의에 나온데로 the_red라는 이름을 추가시켜 준적은 있습니다.