Initial setup to git-gitlab-terraform connection.
PC to AWS connection config.
- create amazon account.
- configure the aws account to use MFA, could be admin permision or limited permission. Use authy app to auhenticate.
- configure aws account with a access key to be used with aws vault.
- install aws-vault
- run aws-vault add “awsuserhere”
- vi ~/.aws/config
add
[awsuserhere]
region=”regionhere”
mfa_serial=”mfaserialhere” mfa serial is under the user credential a string like aws:iam::202575445566:mfa/userforaws
- run ./brew/aws-vault exec userterraform –duration=12h
PC git to Gitalb config.
- Create a ssh public key to remote access in your linux.
- go to gitlab account , user setting and configure ssh key to access gitlab.
- Create a new project
- Configure project to merge files just from members. setting-general-project visibility, pipelines, chose “only project member”.
- Setting-Ci/CD-General pipelines, uncheck public pipelines to not leave the pipeline public.
- protected branches, setting-reposirory-protected branches, Branch: create *-release allowed to merge and to push: just form maintaines.
- Protected tags, setting-repositories-protected tags,Branch: create *-release allowed to create: just form maintaines.
- you can use gti clone, git pull origin, gti add . , git commit -am “comment about change”, git push origin, git checkout -b folder/name
git-lab to aws
create a user to be used by gitlab for CI/CD
configure gitlab to use that user, set variables for aws in Gitlab CI/CD variables of the project.
To use terraform centralized
- Create a S3 bucket to save the terraform state. tfstate
- create a table to save the state, to not have 2 people working at the same time in the same terraform project, using dynamodb table.
3.create the files with the connections to aws from terraform, the files is main.tf
Terrafom {
} - create docker-compose.yml, enviroment where the terraforma is going to run.
Install Docker and docker compose.
Install docker with apt-get install docker
and docker compose with:
1.sudo curl -L “https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose
this is for version 1.27.4 for the last one verify with the site.
after that:
- sudo chmod +x /usr/local/bin/docker-compose
- sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
- initialize terraform
docker-compose -f docker-compose.yml run –rm terraform init.