Skip to content

Commit 8452ff6

Browse files
authored
Merge pull request #52 from hackforla/51-update-contributing-guide
Updating documentation for clarity
2 parents dcda306 + e81594f commit 8452ff6

3 files changed

Lines changed: 118 additions & 25 deletions

File tree

.github/ISSUE_TEMPLATE/pre-work-template-devops-security.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ As a new member on the HfLA devops-security team, fill in the following fields a
2222

2323
- [ ] Before starting to work on the below instructions, make sure to join the #ops Slack Channel. And are a member of `devops-security` repository.
2424
- [ ] Self-assign this issue (gear in right side panel).
25-
- [ ] Add this issue to the Project Board under the Projects section (gear in right side panel).
25+
- [ ] Add this issue to the Project Board CoP: DevOps: Project Board - under the Projects section (gear in right side panel).
2626
- [ ] Attend weekly team meeting, Wednesdays 6-8pm PST.
27-
- [ ] Note: There are no meetings on the 1st-7th of every month.
27+
- [ ] Note: There are no meetings on the 1st Wednesday of every month.
2828
- [ ] Complete the steps in [Creating a personal AWS account](https://github.com/hackforla/devops-security/blob/main/CONTRIBUTING.md#creating-a-personal-aws-account) and [Login as root user & setup MFA](https://github.com/hackforla/devops-security/blob/main/CONTRIBUTING.md#login-as-root-user-&-setup-mfa).
2929
- [ ] Read and follow the instructions in [Setting up IAM and AWS CLI](https://github.com/hackforla/devops-security/blob/main/CONTRIBUTING.md#setting-up-iam-and-aws-cli) for:
3030
- [ ] [Creating an IAM User](https://github.com/hackforla/devops-security/blob/main/CONTRIBUTING.md#create-an-iam-group)
@@ -35,7 +35,9 @@ As a new member on the HfLA devops-security team, fill in the following fields a
3535
- [ ] [Generating user access keys](https://github.com/hackforla/devops-security/blob/main/CONTRIBUTING.md#generating-access-keys-for-aws-cli)
3636
- [ ] Complete the instructions in [AWS Documentation](https://docs.aws.amazon.com/cli/v1/userguide/cli-chap-install.html) and choose your operating system to install AWS CLI.
3737
- [ ] Complete the instruction in [AWS Documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-authentication-short-term.html) to setup the AWS CLI.
38-
- [ ] Read follow the instructions in [Creating a backend state](https://github.com/hackforla/devops-security/blob/main/CONTRIBUTING.md#creating-backend-state).
38+
- [ ] Follow the instructions in [Creating a backend state](https://github.com/hackforla/devops-security/blob/main/CONTRIBUTING.md#creating-backend-state) to create the S3 bucket and DynamoDB table.
39+
- [ ] Create the S3 bucket
40+
- [ ] Create the DynamoDB table
3941
- [ ] Install Terraform locally by following the instructions of the installation guide mentioned in [Installing Terraform](https://github.com/hackforla/devops-security/blob/main/CONTRIBUTING.md#installing-terraform)
4042
- [ ] Install Terraform Docs locally by following the instructions of the installation guide mentioned in [Installing Terraform docs](https://github.com/hackforla/devops-security/blob/main/CONTRIBUTING.md#installing-terraform-docs)
4143
- [ ] Complete the instructions in [Clone the repository](https://github.com/hackforla/devops-security/blob/main/CONTRIBUTING.md#clone-the-repository)
@@ -46,14 +48,14 @@ As a new member on the HfLA devops-security team, fill in the following fields a
4648
git checkout -b issue-number-add-new-iam-user
4749

4850
```
49-
- [ ] Navigate to the `aws-user.tf` file and add your user information and follow the below template.
51+
- [ ] Navigate to the `aws-user.tf` file and add your user information to the end of the file following the below template.
5052

5153
```bash
52-
53-
module "iam_user_testiamuser" {
54+
# Replace USERNAME with your GitHub handle
55+
module "iam_user_USERNAME" {
5456
source = "./modules/aws-users"
5557
56-
user_name = "testiamuser"
58+
user_name = "USERNAME" # Replace with GitHub handle
5759
user_tags = {
5860
"Project" = "devops-security"
5961
"Access Level" = "1"
@@ -63,12 +65,25 @@ As a new member on the HfLA devops-security team, fill in the following fields a
6365
6466
```
6567
- [ ] In your code editor navigate to `terraform` directory. `cd terraform`
68+
69+
Note: You must be authenticated to your AWS account via the CLI for the next commands to work. The above instructions for setting up the CLI will guide you through this process. To check to see if you are authenticated, run `aws sts get-caller-identity`. You should get a response like:
70+
71+
```
72+
{
73+
"UserId": "ABCDEFGHIJKLMNOPQRSTU",
74+
"Account": "012345678910",
75+
"Arn": "arn:aws:iam::012345678910:user/USERNAME"
76+
}
77+
```
78+
If you are unable to authenticate from your local machine using the CLI, post in the #ops channel in Slack so that the team can help you get unblocked.
6679
- [ ] Execute the command `terraform init` to initialize terraform in the directory. Address any failures that arise (if any).
6780
- [ ] Execute the command `terraform plan` this will output a plan replicating the same IAM resources as the devops security account. Address any failures that arise (if any).
68-
- [ ] Then execute the command `terraform apply` this will create all of the resources that are currently managed by Devops Security. All of the resources created here incur zero cost except for the Dynamo DB installation, which should remain in the free tier.
69-
- [ ] ** If you have cost concerns, Run a Terraform Destroy to take down all of the resources you created (don't worry, you can recreate them just as quickly). **
81+
- [ ] Then execute the command `terraform apply` this will create all of the resources that are currently managed by Devops Security. All of the resources created here incur zero cost except for the Dynamo DB installation, which should remain in the free tier. **
82+
- [ ] **If you have cost concerns, Run a Terraform Destroy to take down all of the resources you created (don't worry, you can recreate them just as quickly). If you create resources outside of what's described in this issue, you may incur charges.**
83+
- [ ] Update the README using Terraform Docs to document changes
84+
- [ ] ```terraform-docs -c .terraform.docs.yml .```
7085
- [ ] Once you have tested your changes, stage them in git with
7186
- [ ] `git status` command.
7287
- [ ] then `git add path/to/file` (you can copy from above output for the file path).
73-
- [ ] Commit the changes by executing `git commit -m "briefly describing the changes"`.
88+
- [ ] Commit the changes by executing `git commit -m "brief description of changes"`.
7489
- [ ] Push the changes with `git push --set-upstream origin name-of-branch`

CONTRIBUTING.md

Lines changed: 91 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Below are guidelines for contributing to the devops-security repository hosted o
3232
- [**Submitting changes via git and opening a PR**](#submitting-changes-via-git-and-opening-a-pr)
3333

3434
## **Setting up the local development environment**
35+
The below instructions will walk you through setting up your own AWS account for local development and testing before pushing changes that will effect our infrastructure.
36+
37+
If you've already completed these steps or you aren't making Terraform changes, skip to [Create a branch](https://github.com/hackforla/devops-security/blob/main/CONTRIBUTING.md#create-a-new-branch-where-you-will-work-on-your-issue)
3538

3639
### **Creating a personal AWS account**
3740

@@ -132,41 +135,83 @@ Below are guidelines for contributing to the devops-security repository hosted o
132135
```
133136
<sub>[Back to Table of Contents](#table-of-contents)</sub>
134137
***
138+
The below steps must be completed in order to authenticate to AWS locally via the command line interface (CLI):
135139
- [Install AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
136140
- [Set up the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html)
137141
138142
<sub>[Back to Table of Contents](#table-of-contents)</sub>
139143
***
140144
141-
### **Installing Terraform**
145+
### **Creating Backend State**
142146
143-
Use the [Official HashiCorp install instructions](https://developer.hashicorp.com/terraform/install) for installing terraform.
147+
To facilitate AWS IAM changes using Terraform, it's essential to establish backend state storage.
144148

145-
<sub>[Back to Table of Contents](#table-of-contents)</sub>
146-
***
149+
#### Create S3 bucket
150+
- Region: `us-west-2` (Oregon)
151+
- Name: `USERNAME-hfla-ops-terraform-state`
152+
- Enable versioning
153+
- Enable server-side encryption
147154

148-
### **Creating Backend State**
155+
You can create a bucket from the AWS UI, CloudShell, or from the CLI using the following commands:
156+
157+
##### Step 1: Create the bucket
158+
`aws s3api create-bucket --bucket USERNAME-hfla-ops-terraform-state --region us-west-2 --create-bucket-configuration LocationConstraint=us-west-2`
159+
160+
##### Step 2: Enable versioning
161+
`aws s3api put-bucket-versioning --bucket USERNAME-hfla-ops-terraform-state --versioning-configuration Status=Enabled`
162+
163+
##### Step 3: Enable server-side encryption
164+
```bash
165+
aws s3api put-bucket-encryption --bucket USERNAME-hfla-ops-terraform-state --server-side-encryption-configuration '{
166+
"Rules": [
167+
{
168+
"ApplyServerSideEncryptionByDefault": {
169+
"SSEAlgorithm": "AES256"
170+
}
171+
}
172+
]
173+
}'
174+
```
175+
176+
#### Set up DynamoDB to store the backend state
177+
178+
- Create table `hfla_ops_terraform_table`
179+
- Set partition key to `LockID` with a type of `string`
180+
- Choose on-demand capacity
149181

150-
To facilitate AWS IAM changes using Terraform, it's essential to establish backend state storage. Refer to and follow the instructions outlined in this [issue](https://github.com/hackforla/ops/issues/105) to create the backend state.
182+
You can create the table from the AWS UI, CloudShell, or from the CLI using the following command:
151183

152-
**Note:** Users will need to create their backend state exactly as specified (i.e. using the same naming conventions).
184+
```bash
185+
aws dynamodb create-table \
186+
--table-name hfla_ops_terraform_table \
187+
--attribute-definitions AttributeName=LockID,AttributeType=S \
188+
--key-schema AttributeName=LockID,KeyType=HASH \
189+
--billing-mode PAY_PER_REQUEST
190+
```
153191

154192
<sub>[Back to Table of Contents](#table-of-contents)</sub>
155193
***
156194

157195
### **Creating Local tfvars file**
158196

159-
Atfer creating a backend state, create a ```backend.tfvars``` file in the ```terraform``` directory. It should have content of this format:
197+
After creating a backend state, create a `backend.tfvars` file in the `terraform` directory. It should have content of this format:
160198

161-
```
162-
bucket = "{developer_specific}-hfla-ops-terraform-state"
199+
```terraform
200+
bucket = "USERNAME-hfla-ops-terraform-state"
163201
key = "devops-security/terraform.tfstate"
164202
region = "us-east-2"
165-
dynamodb_table = "{developer_specific}_hfla_ops_terraform_table"
203+
dynamodb_table = "hfla_ops_terraform_table"
166204
encrypt = true
167205
```
168206

169-
Remeber to match these values to the ones in your backend state (and replace {developer-specific} with your actual name)
207+
Remember to match these values to the ones in your backend state (and replace USERNAME with your username)
208+
209+
<sub>[Back to Table of Contents](#table-of-contents)</sub>
210+
***
211+
212+
### **Installing Terraform**
213+
214+
Use the [Official HashiCorp install instructions](https://developer.hashicorp.com/terraform/install) for installing terraform.
170215

171216
<sub>[Back to Table of Contents](#table-of-contents)</sub>
172217
***
@@ -232,35 +277,66 @@ When you've finished working on your issue, follow the steps below to prepare yo
232277
***
233278
234279
### **Terraform Setup and Execution Instructions**
280+
Make the required changes and execute them to see the changes in your own AWS account
235281
236282
- Change into `terraform` directory with
237283
238284
```bash
239285
cd terraform
240286
```
241287
242-
- Next initilize the terraform configuration
288+
- Initialize the terraform configuration
243289
244290
```bash
245291
terraform init --backend-config=backend.tfvars
246292
```
247293
248-
- Then generate and run an execution plan
294+
- Generate and run an execution plan
249295
250296
```bash
251297
terraform plan
252298
```
299+
300+
- Apply your changes
301+
```bash
302+
terraform apply
303+
```
304+
305+
- Optional: delete the resources created
306+
```bash
307+
terraform destroy
308+
```
309+
310+
<sub>[Back to Table of Contents](#table-of-contents)</sub>
311+
***
312+
313+
### Generate Terraform Docs
314+
Terraform docs allow the easy updating of README files inside of Terraform directories
315+
316+
Navigate to the directory where the changes were made
317+
```bash
318+
cd terraform # or other directory
319+
```
320+
```bash
321+
terraform-docs -c .terraform.docs.yml .
322+
```
323+
253324
<sub>[Back to Table of Contents](#table-of-contents)</sub>
254325
***
255326
256327
### **Submitting changes via git and opening a PR**
257328
258329
- We urge developers to be cautious using `git add`. In general it is not advisable to use `git add -all` or `git add .`. Rather, run `git status`, examine the output carefully, and then add only those files specifically related to the current issue. This will ensure that no extraneous files are included in the subsequent commit.
259330
331+
Example:
332+
```bash
333+
git add terraform/aws-users.tf
334+
```
335+
260336
- Then commit the changes with a descriptive message using
261337
262338
```bash
263-
git commit -m "your commit message"
339+
git commit -m "Updating documentation" # Change the message to summarize the changes you've made
264340
```
265341
266342
- Push changes to the remote repository, replace the `branch_name` with the name of the branch you are working on

terraform/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ Resources created by this code repository.
1313
| <a name="module_iam_services_supervisor_group"></a> [iam\_services\_supervisor\_group](#module\_iam\_services\_supervisor\_group) | ./modules/aws-groups | n/a |
1414
| <a name="module_iam_user_JimmyJuarez10"></a> [iam\_user\_JimmyJuarez10](#module\_iam\_user\_JimmyJuarez10) | ./modules/aws-users | n/a |
1515
| <a name="module_iam_user_abbyz123"></a> [iam\_user\_abbyz123](#module\_iam\_user\_abbyz123) | ./modules/aws-users | n/a |
16+
| <a name="module_iam_user_alexe"></a> [iam\_user\_alexe](#module\_iam\_user\_alexe) | ./modules/aws-users | n/a |
1617
| <a name="module_iam_user_awlFCCamp"></a> [iam\_user\_awlFCCamp](#module\_iam\_user\_awlFCCamp) | ./modules/aws-users | n/a |
1718
| <a name="module_iam_user_brittanyms"></a> [iam\_user\_brittanyms](#module\_iam\_user\_brittanyms) | ./modules/aws-users | n/a |
1819
| <a name="module_iam_user_chelseyb"></a> [iam\_user\_chelseyb](#module\_iam\_user\_chelseyb) | ./modules/aws-users | n/a |
1920
| <a name="module_iam_user_freaky4wrld"></a> [iam\_user\_freaky4wrld](#module\_iam\_user\_freaky4wrld) | ./modules/aws-users | n/a |
2021
| <a name="module_iam_user_jbubar"></a> [iam\_user\_jbubar](#module\_iam\_user\_jbubar) | ./modules/aws-users | n/a |
22+
| <a name="module_iam_user_rsakuma"></a> [iam\_user\_rsakuma](#module\_iam\_user\_rsakuma) | ./modules/aws-users | n/a |
2123
| <a name="module_iam_user_samuelusc"></a> [iam\_user\_samuelusc](#module\_iam\_user\_samuelusc) | ./modules/aws-users | n/a |
2224
| <a name="module_iam_user_shikha0428"></a> [iam\_user\_shikha0428](#module\_iam\_user\_shikha0428) | ./modules/aws-users | n/a |
2325
| <a name="module_iam_user_shinjonathan"></a> [iam\_user\_shinjonathan](#module\_iam\_user\_shinjonathan) | ./modules/aws-users | n/a |

0 commit comments

Comments
 (0)