Powered by Terraform.
- Test locally or within docker-compose
You can:
- Build, remote state
Uses a number of open source projects to work properly:
- terraform - open-source infrastructure as code software tool.
Open your favorite Terminal and run these commands.
First, if necessary:
$ mkdir ./iacSecond:
$ git initThird:
$ git clone git@gitlab.com/bcx-sanlam-group/tfremotestate.git Making any change in your source file will update immediately if volume is attached. See todo within compose file.
Before we begin, required environment variables:
$ vi ./.env/app.development.env
# # TF
IAC_ENDPOINT_PROTOCOL=http
IAC_ENDPOINT_HOSTNAME=192.168.43.126
IAC_ENDPOINT_PORT=3001
# # AWS
AWS_ACCESS_KEY=?
AWS_SECRET_KEY=?
AWS_REGION=eu-west-1Easily done in a Docker container. Make required changes within Dockerfile + compose files if necessary. When ready, simply use docker-compose to build your environment. This will create the iac-terra, ... services with necessary dependencies. Once done, simply run the following commends:
For dev, docker compose:
$ docker-compose build
$ docker-compose upVerify the deployment by docker exec.
$ docker exec -it state_iac-terra_1 bashVerify terraform source files, variable(s) will prompt user
$ terraform init
$ terraform fmt
$ terraform validate
$ terraform plan -var 'id=
' -var 'aws_access_key=****' -var 'aws_secret_key=****' -var 'aws_region=eu-west-1'
$ terraform apply -var 'id=5db3181d169cd3001dfd61ab' -var 'aws_access_key=****' -var 'aws_secret_key=****' -var 'aws_region=eu-west-1'
$ terraform destroy -var 'id=5db3181d169cd3001dfd61ab' -var 'aws_access_key=****' -var 'aws_secret_key=****' -var 'aws_region=eu-west-1'Once [jenkins] is online and ready, you need to add credentials of your AWS Account. From the home page click Credentials > System on the left. Under System, click the Global credentials (unrestricted) link to access this default domain. Click Add Credentials on the left.
Kind > Secret text
Secret : "****"
ID : "AWS_ACCESS_KEY"Kind > Secret text
Secret : "****"
ID : "AWS_SECRET_KEY"Kind > Secret text
Secret : "****"
ID : "AWS_REGION"Create a new item, example terraform_state_git, pipeline. Some important considerations or options. Example below, Importantly all options/parameters can be controlled by the pipeline script
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '7'))
}
...
}
Want to contribute? Great! See repo git-repo-url from Maurizio Lupini -Author, Working at ...