- 🛠 Built with Terraform
- 📚 Project for consolidating my knowledge in Terraform after getting the Hashicorp Certified: Terraform Associate certification [2023 August]
- 📄 Uses
terraform-docs
for automated documentation generation - 👮♂️ Uses
terraform fmt -check -recursive
in Github Actions for checking format errors - 🔖 All AWS resources are tagged with the following attributes for better management
Project = var.project ManagedBy = "Terraform"
- Authenticate on AWS with Terraform using one of the supported authentication methods.
- Create a
terraform.tfvars
file at the root of the project that define the following variables.
project = "life-tonystrawberry-codes"
region = "ap-northeast-1"
domain = "tonystrawberry.codes"
- Run
terraform init
to initialize the project (download the providers). - Run
terraform plan
to check and validate the infrastucture changes. - Run
terraform apply
for provisioning the resources. - Login into AWS. Connect to your provisioned EC2 using Session Manager. Follow the steps below.
# Edit the following lines in the wp-config.php file
# using `sudo nano wordpress/wp-config.php`
# define('DB_NAME', 'wordpress-db');
# define('DB_USER', 'wordpress-user');
# define('DB_PASSWORD', 'wordpress');
#
# In the same file, find the section called `Authentication Unique Keys and Salts`
# Replace the values in that section with the output from the following command
# curl -s https://api.wordpress.org/secret-key/1.1/salt/
# define('AUTH_KEY', ' #U$$+[RXN8:b^-L 0(WU_+ c+WFkI~c]o]-bHw+)/Aj[wTwSiZ<Qb[mghEXcRh-');
# define('SECURE_AUTH_KEY', 'Zsz._P=l/|y.Lq)XjlkwS1y5NJ76E6EJ.AV0pCKZZB,*~*r ?6OP$eJT@;+(ndLg');
# define('LOGGED_IN_KEY', 'ju}qwre3V*+8f_zOWf?{LlGsQ]Ye@2Jh^,8x>)Y |;(^[Iw]Pi+LG#A4R?7N`YB3');
# define('NONCE_KEY', 'P(g62HeZxEes|LnI^i=H,[XwK9I&[2s|:?0N}VJM%?;v2v]v+;+^9eXUahg@::Cj');
# define('AUTH_SALT', 'C$DpB4Hj[JK:?{ql`sRVa:{:7yShy(9A@5wg+`JJVb1fk%_-Bx*M4(qc[Qg%JT!h');
# define('SECURE_AUTH_SALT', 'd!uRu#}+q#{f$Z?Z9uFPG.${+S{n~1M&%@~gL>U>NV<zpD-@2-Es7Q1O-bp28EKv');
# define('LOGGED_IN_SALT', ';j{00P*owZf)kVD+FVLn-~ >.|Y%Ug4#I^*LVd9QeZ^&XmK|e(76miC+&W&+^0P/');
# define('NONCE_SALT', '-97r*V/cgxLmp?Zy4zUU4r99QQ_rGs2LTd%P;|_e1tS)8_B/,.6[=UK<J_y9?JWG');
# Allow Wordpress to use permalinks
# using `sudo vim /etc/httpd/conf/httpd.conf` and modify the AllowOverride directive
# <Directory "/var/www/html">
# AllowOverride All
# </Directory>
- As an output, you will get an IP address which allows you to access the website using HTTP (HTTPs is not supported).
- After testing, run
terraform destroy
to destroy all provisioned resources using Terraform.
Name | Version |
---|---|
terraform | 1.5.5 |
aws | 5.13.1 |
Name | Version |
---|---|
aws | 5.13.1 |
Name | Source | Version |
---|---|---|
dns | ./modules/dns | n/a |
ec2 | ./modules/ec2 | n/a |
identity | ./modules/identity | n/a |
network | ./modules/network | n/a |
Name | Type |
---|---|
aws_region.tf-docs-provider-workaround | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
domain | The domain to use for the DNS zone | string |
"tonystrawberry.codes" |
no |
project | The name of the project | string |
"life-tonystrawberry-codes" |
no |
region | The AWS region to launch in | string |
"ap-northeast-1" |
no |
Name | Description |
---|---|
wordpress_public_ip | The public IP address of the EC2 instance |