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
-[**What if you accidentally cloned using the repository URL from the HackForLA Github (instead of the fork on your Github)?**](#what-if-you-accidentally-cloned-using-the-repository-url-from-the-hackforla-github-instead-of-the-fork-on-your-github)
-[**ii. Add an `upstream` remote**](#ii-add-an-upstream-remote)
34
+
-[**Create a new branch where you will work on your issue**](#create-a-new-branch-where-you-will-work-on-your-issue)
35
+
-[**Terraform Setup and Execution Instructions**](#terraform-setup-and-execution-instructions)
36
+
-[**Submitting changes via git and opening a PR**](#submitting-changes-via-git-and-opening-a-pr)
26
37
27
38
## **Setting up the local development environment**
28
39
@@ -37,13 +48,116 @@ Below are guidelines for contributing to the devops-security repository hosted o
37
48
<sub>[Back to Table of Contents](#table-of-contents)</sub>
38
49
***
39
50
51
+
### **Login as root user & setup MFA**
52
+
- Open [AWS Management Console](https://console.aws.amazon.com/).
53
+
- Choose `Root user` and enter your email.
54
+
- Complete security check if prompted.
55
+
- Enter password and authenticate with MFA.
56
+
- Sign in to access the Console Home page.
57
+
- Follow this [guide](https://docs.aws.amazon.com/IAM/latest/UserGuide/enable-virt-mfa-for-root.html) for enabling MFA for the root AWS account.
58
+
59
+
**Note:** Select the `us-west-2` region. It's not required for managing IAM resources, as they are global. However, it's advisable since our other resources are in the same region.
60
+
61
+
<sub>[Back to Table of Contents](#table-of-contents)</sub>
62
+
***
63
+
64
+
## **Setting up IAM and AWS CLI**
65
+
66
+
- Open AWS CloudShell or follow this [link](https://docs.aws.amazon.com/cloudshell/latest/userguide/welcome.html#how-to-get-started)
67
+
-### **Create an IAM User**
68
+
69
+
Run the following commands
70
+
```bash
71
+
aws iam create-user --user-name UserName
72
+
```
73
+
For example if your AWS username was `octocat`:
74
+
75
+
```bash
76
+
aws iam create-user --user-name octocat
77
+
```
78
+
then create a login profile with username and password with
79
+
80
+
```bash
81
+
aws iam create-login-profile --user-name UserName --password ExamplePassword123!
82
+
```
83
+
For example if your AWS username was `octocat`:
84
+
85
+
```bash
86
+
aws iam create-login-profile --user-name octocat --password OctocatIsMyPassword234!
87
+
```
88
+
**Note:** Password length must be 20 characters
89
+
90
+
<sub>[Back to Table of Contents](#table-of-contents)</sub>
91
+
***
92
+
-### **Create an IAM Group**
93
+
94
+
To create an `AdminGroup` run the command
95
+
96
+
```bash
97
+
aws iam create-group --group-name AdminGroup
98
+
```
99
+
<sub>[Back to Table of Contents](#table-of-contents)</sub>
100
+
***
101
+
-### **Attach IAM user to IAM group**
102
+
103
+
Next we need to link the newly created IAM user with the IAM group, use the command
104
+
105
+
```bash
106
+
aws iam add-user-to-group --group-name AdminGroup --user-name UserName
107
+
```
108
+
For example if your AWS username was `octocat`:
109
+
110
+
```bash
111
+
aws iam add-user-to-group --group-name AdminGroup --user-name octocat
112
+
```
113
+
<sub>[Back to Table of Contents](#table-of-contents)</sub>
114
+
***
115
+
-### **Attach `AdministratorAccess` policy to IAM group**
116
+
117
+
Run the command for attaching `AdministratorAccess` policy to the `AdminGroup`
118
+
119
+
```bash
120
+
aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AdministratorAccess --group-name AdminGroup
121
+
```
122
+
<sub>[Back to Table of Contents](#table-of-contents)</sub>
123
+
***
124
+
- Log in as the newly created user instead of continuing to log in as the root user.
125
+
-### **Generating Access Keys for AWS CLI**
126
+
- Open CloudShell
127
+
- Generate the Access Keys for AWS CLI
128
+
129
+
```bash
130
+
aws iam create-access-key --user-name UserName > access_key.json
131
+
```
132
+
- Print the contents of `access_key.json` and copy the contents to a secure location (you'll need the keys when you set up AWS CLI below)
133
+
134
+
```bash
135
+
nano access_key.json
136
+
```
137
+
<sub>[Back to Table of Contents](#table-of-contents)</sub>
- [Set up the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html)
141
+
142
+
<sub>[Back to Table of Contents](#table-of-contents)</sub>
143
+
***
144
+
40
145
### **Installing Terraform**
41
146
42
147
Use the [Official HashiCorp install instructions](https://developer.hashicorp.com/terraform/install) for installing terraform.
43
148
44
149
<sub>[Back to Table of Contents](#table-of-contents)</sub>
45
150
***
46
151
152
+
### **Creating Backend State**
153
+
154
+
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.
155
+
156
+
**Note:** Users will need to create their backend state exactly as specified (i.e. using the same naming conventions).
157
+
158
+
<sub>[Back to Table of Contents](#table-of-contents)</sub>
159
+
***
160
+
47
161
### **Installing Terraform docs**
48
162
49
163
Follow the Terraform docs [installation guide](https://terraform-docs.io/user-guide/installation/)
<sub>[Back to Table of Contents](#table-of-contents)</sub>
149
263
***
264
+
265
+
### **Create a new branch where you will work on your issue**
266
+
267
+
Using the `-b` flag you can also use the `git checkout`command to create a new branch and immediately switch into it.
268
+
269
+
For example, if you create a new issue branch for [Update Contributing document to include next steps - #15](https://github.com/hackforla/devops-security/issues/15):
270
+
271
+
```bash
272
+
git checkout -b update-contributing-guide-15
273
+
```
274
+
275
+
The text after the `-b`, in the example `update-contributing-guide-15`, will be the name of your new branch.
276
+
277
+
**Note:** Choose a branch name that:
278
+
* relates to the issue (No spaces!)
279
+
* includes the issue number
280
+
281
+
**Note:** The format should look like the scheme above where the words are a brief description of the issue that will make sense at a glance to someone unfamiliar with the issue.
282
+
283
+
**Note:** No law of physics will breakif you don't adhere to this scheme, but laws of git will break if you add spaces.
284
+
285
+
When you've finished working on your issue, follow the steps below to prepare your changes to push to your repository.
286
+
287
+
<sub>[Back to Table of Contents](#table-of-contents)</sub>
288
+
***
289
+
290
+
### **Terraform Setup and Execution Instructions**
291
+
292
+
- Change into `terraform` directory with
293
+
294
+
```bash
295
+
cd terraform
296
+
```
297
+
298
+
- Next initilize the terraform configuration
299
+
300
+
```bash
301
+
terraform init
302
+
```
303
+
304
+
- Then generate and run an execution plan
305
+
306
+
```bash
307
+
terraform plan
308
+
```
309
+
<sub>[Back to Table of Contents](#table-of-contents)</sub>
310
+
***
311
+
312
+
### **Submitting changes via git and opening a PR**
313
+
314
+
- 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.
315
+
316
+
- Then commit the changes with a descriptive message using
317
+
318
+
```bash
319
+
git commit -m "your commit message"
320
+
```
321
+
322
+
- Push changes to the remote repository, replace the `branch_name` with the name of the branch you are working on
323
+
324
+
```bash
325
+
git push --set-upstream origin main branch_name
326
+
```
327
+
- Lastly open a PR to merge your changes into the `main` branch.
328
+
329
+
<sub>[Back to Table of Contents](#table-of-contents)</sub>
0 commit comments