In this section, we will execute Terraform commands to create and manage resources on AWS.
First, open a terminal and navigate to the directory containing your Terraform configuration files.
cd path/to/terraform/files
Next, run the following commands:
terraform init
This command initializes Terraform and downloads necessary plugins for the providers declared in the configuration files.
terraform plan
This command examines the configuration and displays the expected changes to be applied when running terraform apply
.
terraform apply -auto-approve
This command applies the changes to the AWS infrastructure automatically without requiring user confirmation.
After running the terraform apply
command successfully, verify on the AWS interface to ensure that the resources have been created and configured as expected.
Successful Apply command:
Check S3:
Check CodeCommit:
Check CodeBuild:
Check CodePipeline:
Access the website via S3 Static Web URL:
Once you have completed your work and want to delete the created resources, you can run the following command:
terraform destroy -auto-approve
This command will automatically delete all resources created by Terraform without requiring user confirmation.