> For the complete documentation index, see [llms.txt](https://terraform201.devart.tv/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://terraform201.devart.tv/2./acm-https.md).

# ACM을 이용한 HTTPS 설정

## ACM 생성 (via 콘솔)

* ACM은 AWS에서 무료로 제공해주는 SSL Certificate 인증서 솔루션입니다. 본인이 가지고 있는 도메인에 대해서는 Certificate를 자유롭게 생성하실 수 있습니다.
* ACM도 테라폼으로 생성해도 되지만, 인증서의 경우에는 자동 Renewal 되기도 하고, 한 번 만들면 수정하는 경우가 거의 없기 때문에 콘솔에서 생성하셔도 무방합니다.

1. AWS Certificate Manager -> Request 클릭

<figure><img src="/files/7gTyyfreR50jBLxF2ETo" alt=""><figcaption></figcaption></figure>

2. Next 클릭

<figure><img src="/files/HE2ZLlpnkuHNOR0TZdvr" alt=""><figcaption></figcaption></figure>

3. 사용하고자 하는 도메인을 입력

   1. 만약 subdomain 모두 같은 인증서를 사용하고 싶다면, \* 을 붙이시면 됩니다.
   2. 인증 방식은 DNS validation 을 사용합니다. 스스로 도메인을 가지고 있기 때문에, Route53에 자동으로 도메인 레코드가 등록되므로 인증이 훨씬 간편합니다.

   <figure><img src="/files/pKa6lROOXJirwUTBvVSw" alt=""><figcaption></figcaption></figure>
4. 상태가 `Issued` 가 될때까지 기다립니다.

<figure><img src="/files/PTDJoQ9JY4kZx6k9lqua" alt=""><figcaption></figcaption></figure>

## ACM 적용

이제 만들어놓은 ACM을 적용해보겠습니다.

`service.tf` 파일에 아래와 같이 값을 넣습니다.

* `acm_external_ssl_certificate_arn` : 위에서 생성한 ACM의 ARN
* 위 변수명은 원하시는대로 변경하셔도 됩니다. 단, 변경하신 이름을 반드시 `_modules/hello/variables.tf` 에 등록해주셔야 합니다.

```bash
  # Route53 variables
  acm_external_ssl_certificate_arn  = "arn:aws:acm:ap-northeast-2:816736805842:certificate/9d4a371f-80c5-4087-9cb5-b2636f554da7"
```

해당 변수는 모듈에서 사용하기 때문에 모듈에 같은 이름의 variable을 정의해주셔야 합니다.

```hcl
variable "acm_external_ssl_certificate_arn" {
  description = "ssl cert id"
  default     = ""
}
```

이후에 해당 SSL을 등록하기 위해서 443번 포트로 요청을 받을 타켓 그룹을 생성하고, 해당 타켓 그룹에 위 ACM을 등록합니다.

```hcl
#################### Listener for HTTPS service
resource "aws_lb_listener" "external_443" {
  load_balancer_arn = aws_lb.external.arn
  port              = "443"
  protocol          = "HTTPS"

  # If you want to use HTTPS, then you need to add certificate_arn here.
  certificate_arn   = var.acm_external_ssl_certificate_arn

  default_action {
    target_group_arn = aws_lb_target_group.external.arn
    type             = "forward"
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://terraform201.devart.tv/2./acm-https.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
