Skip to content

Commit cf9bc7d

Browse files
authored
Merge pull request #49 from arunlalp/master
Update: Readme and iam permissions of the karpenter
2 parents 8a8f7ce + 037d41a commit cf9bc7d

File tree

2 files changed

+180
-355
lines changed

2 files changed

+180
-355
lines changed

README.md

Lines changed: 178 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,178 @@
1-
## Terraform AWS
1+
# terraform-awsAdd commentMore actions
2+
Terraform AWS provisioning examples for beginners
3+
4+
## Hit the Star! ⭐
5+
If you are planning to use this Terraform repo for learning, please hit the star. Thanks!
6+
7+
## Terraform Init With s3 Backend
8+
9+
```
10+
terraform init \
11+
-backend-config="key=dev/vpc.tfstate" \
12+
-backend-config="bucket=dcube-terraform-state" \
13+
-backend-config="region=us-west-2" \
14+
-backend-config="dynamodb_table=terraform-state-lock" \
15+
-var-file=../../../vars/dev/vpc.tfvars
16+
```
17+
18+
#### VPC Provisioning
19+
20+
cd into the `environments/dev/vpc` directory and run the following commands:
21+
22+
1. Init Terraform in the directory `environments/dev/vpc`
23+
24+
```
25+
terraform init
26+
```
27+
2. To preview the changes in code
28+
29+
```
30+
terraform plan -var-file=../../../vars/dev/vpc.tfvars
31+
```
32+
3. To apply the changes
33+
34+
```
35+
terraform apply -var-file=../../../vars/dev/vpc.tfvars
36+
```
37+
4. To destroy the resources created using the code
38+
39+
```
40+
terraform destroy -var-file=../../../vars/dev/vpc.tfvars
41+
42+
43+
#### RDS Provisioning
44+
45+
cd into the `environments/dev/rds` directory and run the following commands:
46+
47+
1. Init Terraform in the directory `environments/dev/rds`
48+
49+
```
50+
terraform init
51+
```
52+
2. To preview the changes in code
53+
54+
```
55+
terraform plan -var-file=../../../vars/dev/rds.tfvars
56+
```
57+
3. To apply the changes
58+
59+
```
60+
terraform apply -var-file=../../../vars/dev/rds.tfvars
61+
```
62+
4. To destroy the resources created using the code
63+
64+
```
65+
terraform destroy -var-file=../../../vars/dev/rds.tfvars
66+
```
67+
68+
### ALB and ASG Provisioning
69+
70+
cd into the `environments/dev/alb-asg` directory and run the following commands:
71+
72+
1. Init Terraform in the directory `environments/dev/alb-asg`
73+
74+
```
75+
terraform init
76+
```
77+
2. To preview the changes in code
78+
79+
```
80+
terraform plan -var-file=../../../vars/dev/alb-asg.tfvars
81+
```
82+
3. To apply the changes
83+
84+
```
85+
terraform apply -var-file=../../../vars/dev/alb-asg.tfvars
86+
```
87+
4. To destroy the resources created using the code
88+
89+
```
90+
terraform destroy -var-file=../../../vars/dev/alb-asg.tfvars
91+
```
92+
93+
## EC2 Instance Provisioning
94+
95+
1. Navigate to the `environment/dev` folder:
96+
97+
```bash
98+
cd environment/dev
99+
```
100+
101+
2. Open the `ec2.tfvars` file and modify it with your desired details. This file contains variables used in the Terraform configuration.
102+
103+
### Deployment
104+
105+
1. Initialize Terraform in the working directory:
106+
107+
```bash
108+
terraform init
109+
```
110+
111+
2. Create an execution plan:
112+
113+
```bash
114+
terraform plan -var-file=../../../vars/dev/ec2.tfvars
115+
```
116+
117+
3. Apply the changes to create the EC2 instance:
118+
119+
```bash
120+
terraform apply -var-file=../../../vars/dev/ec2.tfvars
121+
```
122+
123+
4. To destroy the EC2 instance and associated resources:
124+
125+
```bash
126+
terraform destroy -var-file=../../../vars/dev/ec2.tfvars
127+
```
128+
129+
**Note**: Always review the execution plan (`terraform plan`) before applying changes to avoid unintended modifications.
130+
131+
## AWS Organization Tag Policy Creation.
132+
133+
1. Navigate to the `environment/dev` folder:
134+
135+
```bash
136+
cd environment/tag-policy
137+
```
138+
139+
2. Open the `tag-policy.tfvars` file and modify it with your desired details. This file contains variables used in the Terraform configuration.
140+
141+
### Deployment
142+
143+
1. Initialize Terraform in the working directory:
144+
145+
```bash
146+
terraform init
147+
```
148+
149+
2. Create an execution plan:
150+
151+
```bash
152+
terraform plan -var-file=../../../vars/dev/tag-policy.tfvars
153+
```
154+
155+
3. Apply the changes to create the Tag Policy:
156+
157+
```bash
158+
terraform apply -var-file=../../../vars/dev/tag-policy.tfvars
159+
```
160+
161+
4. To destroy the Tag Policy:
162+
163+
```bash
164+
terraform destroy -var-file=../../../vars/dev/tag-policy.tfvars
165+
```
166+
167+
**Note**: Always review the execution plan (`terraform plan`) before applying changes to avoid unintended modifications.
168+
169+
## Terraform Command Reference
170+
171+
Update all outputs:
172+
173+
<pre>terraform refresh</pre>
174+
175+
Show all outputs:
176+
177+
<pre>terraform show</pre>
178+

0 commit comments

Comments
 (0)