You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -118,22 +118,28 @@ _**Note**_: Engineers *must* have access and permissions to create AWS resources
118
118
- Terraform Documentation: The official Terraform documentation is an exhaustive resource that covers everything from installation to advanced topics. https://developer.hashicorp.com/terraform/docs
119
119
- Terraform/AWS Intro: HashiCorp provides an official tutorial that covers the basics of Terraform and helps you get started with deploying infrastructure into AWS. https://developer.hashicorp.com/terraform/tutorials/aws-get-started
120
120
- Terraform AWS Provider Documentation: If you're using Terraform with AWS, this documentation provides detailed information on the available resources and data sources. https://registry.terraform.io/providers/hashicorp/aws/latest/docs
121
-
- Terraform module published by the dibbs-ecr-viewer DevOps teams this repo uses: https://registry.terraform.io/modules/CDCgov/dibbs-ecr-viewer/aws/latest
121
+
- Terraform module (git source): The ECS module is sourced directly from the [terraform-aws-dibbs-ecr-viewer repository](https://github.com/CDCgov/terraform-aws-dibbs-ecr-viewer). See Section 4.3 for details on current module sources.
122
122
123
123
[Return to Table of Contents](#table-of-contents)
124
124
125
125
## 4.2 Helper Scripts
126
126
127
127
**If you are familiar with terraform, have setup a backend, understand terraform deployment workflows, know how to validate terraform, or are otherwise opinionated about how you want to run things, feel free to skip this section**
128
-
- We have several helper scripts that will assist you with setting up your AWS backend and deploying your AWS resources.
128
+
- We have several helper scripts that will assist you with setting up your AWS backend and deploying your AWS resources.
129
129
- These scripts are located in the **terraform/utilities** folder, the **terraform/implementation/setup** folder and the **terraform/implementation/ecs** folder.
130
-
- The **utilities** folder contains scripts that will assist in generating terraform docs, formatting and linting terraform code.
131
-
- The **setup.sh** script will assist you with creating the terraform state and .env files to be used later, also sets up OIDC for your GitHub workflows.
132
-
- The **deploy.sh** script will assist you with deploying your ECS module from your development machine.
130
+
131
+
| Folder | Purpose |
132
+
|--------|---------|
133
+
|`terraform/utilities`| Scripts for generating terraform docs, formatting and linting code |
134
+
|`terraform/implementation/setup`| Creates the terraform backend (S3 state bucket, DynamoDB lock table) and OIDC configuration |
135
+
|`terraform/implementation/ecs`| Deploys the ECS module (eCR Viewer application infrastructure) |
136
+
137
+
- The **setup.sh** script creates the terraform state backend and .env files. It also sets up OIDC for GitHub workflows.
138
+
- The **deploy.sh** script deploys your ECS module from your development machine.
133
139
134
140
_**Note**_: It is not recommended to run these scripts without reviewing them and understanding their limitations.
135
141
136
-
_**Note**_: It is not recommended to use these scripts to automate your terraform deployments, please see the [GitHub workflows](https://github.com/CDCgov/dibbs-aws/tree/main/.github/workflows) for examples on how to do that.
142
+
_**Note**_: It is not recommended to use these scripts to automate your terraform deployments. Please see the [GitHub workflows](https://github.com/CDCgov/dibbs-aws/tree/main/.github/workflows) for examples of CI/CD deployment.
137
143
138
144
**Terraform validation and docs with `./utils.sh`**
139
145
* In your terminal, navigate to the _/terraform/utilities_ folder.
@@ -154,28 +160,45 @@ The `setup.sh` scripts will assist you with creating the terraform state and tfv
154
160
155
161
The setup.sh script will create the following files:
156
162
157
-
-_tfstate.tfvars_
158
-
-_.env_
159
-
-_terraform.state_
163
+
-_tfstate.tfvars_ - Terraform variables for the state backend configuration
164
+
-_.env_ - Environment variables used by deployment scripts
165
+
-_terraform.state_ - Local terraform state file (if using local backend)
166
+
167
+
**Deploy Your ECS Module with `./deploy.sh`**
168
+
169
+
It is highly recommended to create a new directory per environment that is launched. To do so, run:
The benefits of doing this reduce the likelihood of conflicts and allow each environment to run different versions of the same module.
174
+
175
+
To deploy your ECS Module from your local machine:
176
+
177
+
1. Navigate to your working directory:
178
+
```bash
179
+
cd terraform/implementation/ecs/
180
+
# or for a custom environment:
181
+
cd terraform/implementation/<ENVIRONMENT_NAME>
182
+
```
183
+
184
+
2. Run the deploy script for your designated environment:
185
+
```bash
186
+
./deploy.sh -e <ENVIRONMENT>
187
+
```
160
188
161
-
**Deploy Your ECS Module with `./deploy`**
162
-
* It is highly recommended to create a new directory per environment that is launched, to do so run `cp terraform/implementation/ecs terraform/implementation/<ENVIRONMENT>`.
163
-
* The benefits of doing this reduces the likelyhood of conflicts and allows each environment to run different versions of the same module.
164
-
* To run your ECS Module Changes in your local terminal, navigate to your working directory, ` cd terraform/implementation/ecs/` or `cd terraform/implementation/<ENVIRONMENT>`
165
-
* In your terminal run the deploy script for your designated environment `./deploy.sh -e <ENVIRONMENT>`.
189
+
_**Note**_: The `-e` flag specifies the environment (e.g., `dev`, `test`, `prod`). This can match your `<ENVIRONMENT_NAME>` directory naming convention, or be any environment name your team desires.
166
190
167
-
_**Note**_: The _-e_ tag stands for environment and you can specify `dev`, `test`, `prod`, this can match your `<ENVIRONMENT>` naming convention.
168
-
or whatever environment your team desires.
191
+
For non-interactive deployments, ensure you have a `.env` file with the required variables before running deploy.sh. See the [setup.sh](https://github.com/CDCgov/dibbs-aws/blob/main/terraform/implementation/setup/setup.sh) script for the expected format.
169
192
170
193
-[Return to Table of Contents](#table-of-contents)
171
194
172
195
## 4.3 Modules used in this repository
173
196
174
-
**Modules pulled from the Terraform Registry**
175
-
-[terraform-aws-dibbs-ecr-viewer](https://registry.terraform.io/modules/CDCgov/dibbs-ecr-viewer/aws/latest) - This module is used to deploy the eCR Viewer application to AWS.
176
-
-[vpc](https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/latest) - This module is used to deploy the VPC for the ECS module.
197
+
**Remote sources:**
198
+
-[terraform-aws-dibbs-ecr-viewer](https://github.com/CDCgov/terraform-aws-dibbs-ecr-viewer) - This module deploys the eCR Viewer application to AWS. Currently using git source: `git::https://github.com/CDCgov/terraform-aws-dibbs-ecr-viewer.git?ref=alis/feature/checkov-workflow`. See the [ECS module README](./terraform/implementation/ecs/README.md) for detailed configuration options.
199
+
-[terraform-aws-modules/vpc/aws](https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/latest) - This module provisions the VPC infrastructure for the ECS module.
177
200
178
-
**Local modules**
201
+
**Local modules:**
179
202
-[oidc](./terraform/modules/oidc/README.md) - OIDC module, used to setup OIDC for GitHub workflows
180
203
-[tfstate](./terraform/modules/tfstate/README.md) - TFState module, used to setup the terraform state backend and lock table
181
204
-[db](./terraform/modules/db/README.md) - Database module, used to setup the database for the ECS module
@@ -185,17 +208,72 @@ or whatever environment your team desires.
185
208
**Use the dibbs-aws repository**
186
209
187
210
1. Select to create your own repo from this template, or fork it to your own repository.
188
-
1. Clone the repository to your local machine.
189
-
2. Make a new branch for your changes: `git checkout -b <BRANCH>`.
190
-
3. Make any changes required by your team to the terraform configurations.
191
-
4. Add and commit changes to your working branch: `git add . && git commit -m "Your message here"`.
192
-
5. Push your changes to your github repository: `git push origin <BRANCH>`.
193
-
6. Open a Pull Request so that your team can review your changes and testing can be done.
194
-
7. Go back to step 4 until your changes are approved.
195
-
8. Once your changes are approved, merge your changes into the main branch.
211
+
2. Clone the repository to your local machine.
212
+
3. Make a new branch for your changes: `git checkout -b <BRANCH>`.
213
+
4. Make any changes required by your team to the terraform configurations.
214
+
5. Add and commit changes to your working branch: `git add . && git commit -m "Your message here"`.
215
+
6. Push your changes to your github repository: `git push origin <BRANCH>`.
216
+
7. Open a Pull Request so that your team can review your changes and testing can be done.
217
+
8. Go back to step 4 until your changes are approved.
218
+
9. Once your changes are approved, merge your changes into the main branch.
196
219
197
-
**Terrform Commands**
220
+
**Terraform Commands**
198
221
199
-
- Please review these docs for specific help understanding and running terraform commands: [Terraform Commands](#41-requirements)
222
+
For help with terraform commands, please visit the [official Terraform documentation](https://developer.hashicorp.com/terraform/tutorials/aws-get-started).
200
223
201
-
-[Return to Table of Contents](#table-of-contents)
224
+
[Return to Table of Contents](#table-of-contents)
225
+
226
+
---
227
+
228
+
## Before You Begin
229
+
230
+
Ensure you have the following prerequisites before deploying:
231
+
232
+
-**AWS Account** with permissions for IAM, VPC, ECS, RDS, S3, DynamoDB, ACM, and Route 53
233
+
-**Terraform** version 1.0.0+ installed locally
234
+
-**AWS CLI** version 2+ configured with appropriate credentials
235
+
-**GitHub repository** (for OIDC configuration if using CI/CD)
236
+
-**SSL certificate** in AWS Certificate Manager (ACM) for your domain
237
+
-**Route 53 hosted zone ID** (if using a custom domain)
238
+
- For non-integrated auth: OAuth application credentials from your provider
239
+
240
+
---
241
+
242
+
## Quick Start
243
+
244
+
Get started deploying this infrastructure in under 10 minutes:
For detailed step-by-step instructions, see [Section 4.2 Helper Scripts](#42-helper-scripts).
263
+
264
+
---
265
+
266
+
## Common Issues and Solutions
267
+
268
+
| Issue | Solution |
269
+
|-------|----------|
270
+
| Backend not initialized error | Run `setup.sh` first to initialize the S3 backend before deploying ECS |
271
+
| OIDC token errors | Verify your GitHub repository name matches exactly (format: `org/repo`) and the OIDC role trust policy is configured correctly |
272
+
| Database connection fails | Check that security group rules allow traffic from ECS task subnet to RDS, and that the database type in `tfvars` matches your configuration |
273
+
| SSL certificate errors | Ensure the cert is issued by ACM (not imported) and in the same region as your deployment (typically `us-east-1` for ALB) |
274
+
| Permission denied on scripts | Run `chmod +x terraform/implementation/setup/setup.sh` and `chmod +x terraform/implementation/ecs/deploy.sh`|
275
+
| State lock error | Wait for any existing Terraform operations to complete, or remove the `.terraform.lock.hcl` file if stale |
0 commit comments