https://github.com/erpushpinderrana/jenkins-terraform-aws
https://github.com/erpushpinderrana/jenkins-terraform-aws
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/erpushpinderrana/jenkins-terraform-aws
- Owner: erpushpinderrana
- License: mit
- Created: 2020-10-01T19:18:34.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-09T19:16:10.000Z (almost 5 years ago)
- Last Synced: 2025-05-15T13:51:26.416Z (5 months ago)
- Language: Dockerfile
- Size: 49.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Jenkins Terraform AWS Pipeline (Basic Demo)
If Jenkins is already running and have Terraform installed then no need to spin up the Jenkins using jenkins_script. In case, if you need to setup the Jenkins too then you should follow the instructions in [Jenkins Setup](https://github.com/erpushpinderrana/jenkins-terraform-aws/tree/master/jenkins_scripts).
When Terraform is installed in Jenkins then we could use this demo code to spin up a new EC2 instance in AWS.
## Prerequisites
Update the AWS access and secret keys in [provider.tf](https://github.com/erpushpinderrana/jenkins-terraform-aws/blob/master/provider.tf) file.## Quick Setup
1. Configure Jenkins with [Jenkins Groovy](https://github.com/erpushpinderrana/jenkins-terraform-aws/blob/master/jenkins_scripts/pipeline.groovy) script.

2. Run the build.

3. If the build is successful then a new EC2 instance will be available in your AWS account.## Important Notes
* Update the correct AWS credentials in the provider.tf file.
* We may try this terraform repo by installing terraform on local machine.## Important Commands
* ``terraform init -input=false -var-file=vars.tfvars`` To initialize a working directory containing Terraform configuration files.
* ``terraform plan -input=false -var-file=vars.tfvars`` Create an execution plan.
* ``terraform apply -input=false -var-file=vars.tfvars`` To apply the changes required to reach the desired state of the configuration.
* ``terraform plan -input=false -var-file=vars.tfvars -out changes.terraform`` Capture the required changes to a separate terraform file to reach the desired state of the configuration.
* ``terraform apply changes.terraform`` To apply the changes of pre-determined set of actions generated by a terraform plan execution plan.
* ``terraform apply changes.terraform`` Terminates resources defined in your Terraform configuration.## References
* https://github.com/wardviaene/terraform-course
* https://github.com/wardviaene/jenkins-course