Run the setup script:
./scripts/setup.shImportant: You will need to logout/login in order to be added to the "docker" group
Before starting the service, create the required credentials. The './scripts/setup.sh' script will execute a './scripts/setup-accounts.sh' script in order to create the needed credentials.
Already executed with './scripts/setup-accounts.sh'. Jenkins needs a GitHub token to clone the repository.
https://github.com/settings/personal-access-tokens/new?name=Azure%20Infrastructure%20Lab&description=Token%20for%20Jenkins%20Pipeline&expires_in=30&contents=read
Create the token and save it securely.
Already executed with './scripts/setup-accounts.sh'. Terraform uses an Azure Service Principal to authenticate with Azure.
az login
az account show
az ad sp create-for-rbac \
--name azure-infrastructure-lab \
--role Contributor \
--scopes /subscriptions/<subscription_id>The output will be similar to:
{
"appId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"password": "xxxxxxxxxxxxxxxx",
"tenant": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}Save these values:
clientId -> appId
clientSecret -> password
tenantId -> tenant
subscriptionId -> Azure subscription ID
Create:
docker/.env
Add:
GITHUB_USERNAME=<github_username>
GITHUB_TOKEN=<github_token>
AZURE_CLIENT_ID=<client_id>
AZURE_CLIENT_SECRET=<client_secret>
AZURE_TENANT_ID=<tenant_id>
AZURE_SUBSCRIPTION_ID=<subscription_id>
VAULT_ADMIN_USER=<vault_user>
VAULT_ADMIN_PASSWORD=<vault_pass>Will build an image for Jenkins and Vault and do the initial setup.
cd docker
./docker-start.shOpen:
Jenkins: http://localhost:8080
Vault: http://localhost:8200/
- For Jenkins and Vault, use the default credentials:
Username: admin
Password: admin
The project includes a Jenkins Pipeline that automates the deployment of the Terraform infrastructure. It uses Hashicorp Vault to store passwords and certificates.
devprod
- Initialize and validate the Terraform configuration.
- Run a Checkov security scan.
- Generate the Terraform execution plan.
- Wait for manual approval.
- Apply the infrastructure changes.
Infrastructure components can be enabled or disabled through pipeline parameters, for example:
- Azure Virtual Machine
- Azure SQL Database
.
├── ansible
├── docker
│ ├── jenkins
│ │ ├── casc
│ │ └── jobs
│ └── vault
│ ├── config
│ ├── init
│ ├── logs
│ └── secrets
├── scripts
└── terraform
├── environments
│ ├── dev
│ └── prod
└── modules
├── nsg
├── nsg_rule
├── resource_group
├── sql_database
├── subnet
├── virtual_network
└── vm