Trên GitHub, gruntwork-io/terragrunt-infrastructure-live-example đã đạt 865 sao, nhóm Developer Tools, ngôn ngữ HCL. A repo used to show examples file/folder structures you can use with Terragrunt and Terraform
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
[!WARNING]
This repository has been deprecated in favor of terragrunt-infrastructure-live-stacks-example. Please use the new repository for the latest best practices and features.
Take special notice of the Migration Guide specifically written to help you migrate from using this repo to the new one.
Example infrastructure-live for Terragrunt
This repo, along with the terragrunt-infrastructure-modules-example
repo, show an example file/folder structure
you can use with Terragrunt to keep your
OpenTofu and Terraform code DRY. For background information,
check out the Keep your code DRY
section of the Terragrunt documentation.
This repo shows an example of how to use the modules from the terragrunt-infrastructure-modules-example repo to
deploy an Auto Scaling Group (ASG) and a MySQL DB across three environments (qa, stage, prod) and two AWS accounts
(non-prod, prod), all with minimal duplication of code. That's because there is just a single copy of
the code, defined in the terragrunt-infrastructure-modules-example repo, and in this repo, we solely define
terragrunt.hcl files that reference that code (at a specific version, too!) and fill in variables specific to each
environment.
Be sure to read through the Terragrunt documentation on DRY
Architectures to understand the
features of Terragrunt used in this folder organization.
Note: This code is solely for demonstration purposes. This is not production-ready code, so use at your own risk. If
you are interested in battle-tested, production-ready Terraform code, check out Gruntwork.
How do you deploy the infrastructure in this repo?
Pre-requisites
Install OpenTofu version 1.6.0 or newer and
Terragrunt version v0.52.0 or newer.
Update the bucket parameter in the root.hcl file. We use S3 as a Terraform
backend to store your
state, and S3 bucket names must be globally unique. The name currently in
the file is already taken, so you'll have to specify your own. Alternatives, you can
set the environment variable TG_BUCKET_PREFIX to set a custom prefix.
Update the account_name and aws_account_id parameters in non-prod/account.hcl and
prod/account.hcl with the names and IDs of accounts you want to use for non production and
production workloads, respectively.
Configure your AWS credentials using one of the supported authentication
mechanisms.
Deploying a single module
cd into the module's folder (e.g. cd non-prod/us-east-1/qa/mysql).
Note: if you're deploying the MySQL DB, you'll need to configure your DB password as an environment variable:
export TF_VAR_master_password=(...).
Run terragrunt plan to see the changes you're about to apply.
If the plan looks good, run terragrunt apply.
Deploying all modules in a region
cd into the region folder (e.g. cd non-prod/us-east-1).
Configure the password for the MySQL DB as an environment variable: export TF_VAR_master_password=(...).
Run terragrunt run-all plan to see all the changes you're about to apply.
If the plan looks good, run terragrunt run-all apply.
Testing the infrastructure after it's deployed
After each module is finished deploying, it will write a bunch of outputs to the screen. For example, the ASG will
output something like the following:
A minute or two after the deployment finishes, and the servers in the ASG have passed their health checks, you should
be able to test the url output in your browser or with curl:
curl http://webserver-example-prod-1234567890.us-east-1.elb.amazonaws.com:80
Hello, World
Similarly, the MySQL module produces outputs that will look something like this:
Account: At the top level are each of your AWS accounts, such as stage-account, prod-account, mgmt-account,
etc. If you have everything deployed in a single AWS account, there will just be a single folder at the root (e.g.
main-account).
Region: Within each account, there will be one or more AWS
regions, such as
us-east-1, eu-west-1, and ap-southeast-2, where you've deployed resources. There may also be a _global
folder that defines resources that are available across all the AWS regions in this account, such as IAM users,
Route 53 hosted zones, and CloudTrail.
Environment: Within each region, there will be one or more "environments", such as qa, stage, etc. Typically,
an environment will correspond to a single AWS Virtual Private Cloud (VPC), which
isolates that environment from everything else in that AWS account. There may also be a _global folder
that defines resources that are available across all the environments in this AWS region, such as Route 53 A records,
SNS topics, and ECR repos.
Resource: Within each environment, you deploy all the resources for that environment, such as EC2 Instances, Auto
Scaling Groups, ECS Clusters, Databases, Load Balancers, and so on. Note that the code for most of these
resources lives in the terragrunt-infrastructure-modules-example repo.
Creating and using root (account) level variables
In the situation where you have multiple AWS accounts or regions, you often have to pass common variables down to each
of your modules. Rather than copy/pasting the same variables into each terragrunt.hcl file, in every region, and in
every environment, you can inherit them from the inputs defined in the root.hcl file.
What to do with .terraform.lock.hcl files
When you run terragrunt commands you may find that .terraform.lock.hcl files are created in your working directories.
These files are intentionally not committed to this example repository, but you definitely should in your own repositories!
They help make sure that your IaC results in reproducible infrastructure. For more on this, read Lock File Handling docs.
How to get help
If you need help troubleshooting usage of this repo, or Terragrunt in general, check out the Support docs.
gruntwork-io/terragrunt-infrastructure-live-example thuộc nhóm Developer Tools trên TopGit, cùng 3 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về gruntwork-io/terragrunt-infrastructure-live-example ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/gruntwork-io/terragrunt-infrastructure-live-example là nguồn chính thức.
gruntwork-io/terragrunt-infrastructure-live-example có bao nhiêu sao?
gruntwork-io/terragrunt-infrastructure-live-example có 865 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/gruntwork-io/terragrunt-infrastructure-live-example. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
gruntwork-io/terragrunt-infrastructure-live-example có phải mã nguồn mở không?
Có — gruntwork-io/terragrunt-infrastructure-live-example phát hành theo license Apache-2.0, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/gruntwork-io/terragrunt-infrastructure-live-example.
gruntwork-io/terragrunt-infrastructure-live-example còn đang phát triển không?
Commit gần nhất trên gruntwork-io/terragrunt-infrastructure-live-example là 1.3 năm trước (theo timestamp GitHub). Repo có 492 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
gruntwork-io/terragrunt-infrastructure-live-example dùng license gì?
gruntwork-io/terragrunt-infrastructure-live-example phát hành theo license Apache-2.0. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
gruntwork-io/terragrunt-infrastructure-live-example là gì?
gruntwork-io/terragrunt-infrastructure-live-example (gruntwork-io/terragrunt-infrastructure-live-example) là dự án HCL trên GitHub. Theo mô tả gốc: A repo used to show examples file/folder structures you can use with Terragrunt and Terraform
gruntwork-io/terragrunt-infrastructure-live-example viết bằng ngôn ngữ gì?
gruntwork-io/terragrunt-infrastructure-live-example chủ yếu viết bằng HCL. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
terragrunt-infrastructure-live-example có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về terragrunt-infrastructure-live-example.