https://github.com/zkfmapf123/hcl-tools-template
mini infra with terraform, packer, ansible
https://github.com/zkfmapf123/hcl-tools-template
Last synced: 4 months ago
JSON representation
mini infra with terraform, packer, ansible
- Host: GitHub
- URL: https://github.com/zkfmapf123/hcl-tools-template
- Owner: zkfmapf123
- Created: 2023-07-08T11:37:23.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-07-08T14:57:48.000Z (almost 3 years ago)
- Last Synced: 2025-01-13T09:38:25.095Z (over 1 year ago)
- Language: HCL
- Size: 61.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Terraform + Packer + Ansible
## Architecture

## Folder Architecture
```
|- modules (terraform module)
|- template (packer + ansible template)
main.tf (main 파일)
```
## Todo
- Terraform
- [x] vpc
- [x] nat gateway
- [x] subnets
- [x] ec2 from read data aws_ami
- Packer
- [x] make openvpn ec2 ami
- [x] make grafana ec2 ami
- Ansible
## Execute
```
// ami 설치
cd infra/packer-templates/openvpn && packer init . && packer build .
cd infra/packer-templates/grafana && packer init . && packer build .
or
cd infra/pakcer-templates && make build
// terraform 구성
cd infra && terraform init && terraform apply
```
## 참고
- cloud-init status --wait
```
해당 명령어는 user_data 실행 후 provisoning 되도록 하는 명령어
```
- --restart unless-stopped
```
// 해당 명령어를 사용하여 ami가 실행되면 바로 구동이 될수 있도록 함.
docker run \
-d \
-p 3000:3000 \
--restart unless-stopped \
--name=grafana \
grafana/grafana:$GRAFANA_VERSION
```
- set -euf -o pipefail
```
shell 파일 맨처음 위치한 명령어로써,
해당 shell파일이 실패했을 경우 바로 종료한다 라는 의미...
```
- openvpn의 run-docker-openvpn.sh은 파일 copy만 하는경우
```
open-vpn의 경우 해당 인스턴스의 public_ip가 필요한데,
pakcer의 경우 ami를 만들때의 public_ip와 실제 인스턴스가 running 되고난 후의 public_ip가 상이하기 때문에...
```