forked from AdminTurnedDevOps/DevOps-The-Hard-Way-AWS
-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from thomast1906/updates
initial updates
- Loading branch information
Showing
28 changed files
with
358 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,86 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
terraform: | ||
name: 'Terraform' | ||
terraform-fmt-check: | ||
if: github.event_name == 'pull_request' | ||
defaults: | ||
run: | ||
working-directory: "./Terraform-AZURE-Services-Creation/AKS" | ||
name: Terraform | ||
environment: production | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
env: | ||
ARM_CLIENT_ID: ${{ secrets.AZURE_AD_CLIENT_ID }} | ||
ARM_CLIENT_SECRET: ${{ secrets.AZURE_AD_CLIENT_SECRET }} | ||
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
ARM_TENANT_ID: ${{ secrets.AZURE_AD_TENANT_ID }} | ||
TF_VERSION: 1.5.7 | ||
runs-on: ubuntu-latest | ||
environment: production | ||
|
||
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
|
||
tf_resource_group_name: "thomasthorntoncloud" | ||
tf_storage_account_name: "thomasthorntontfstate" | ||
tf_state_container: "devopsthehardwaygithub" | ||
tf_state_key: "terraform.tfstate" | ||
steps: | ||
# Checkout the repository to the GitHub Actions runner | ||
- name: Checkout | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: 'Terraform Format' | ||
uses: hashicorp/terraform-github-actions@master | ||
with: | ||
tf_actions_version: ${{ env.TF_VERSION }} | ||
tf_actions_subcommand: 'fmt' | ||
tf_actions_working_dir: "./Terraform-AZURE-Services-Creation/AKS" | ||
|
||
- name: 'Terraform Init' | ||
uses: hashicorp/terraform-github-actions@master | ||
with: | ||
tf_actions_version: ${{ env.TF_VERSION }} | ||
tf_actions_subcommand: 'init' | ||
tf_actions_working_dir: "./Terraform-AZURE-Services-Creation/AKS" | ||
|
||
- name: 'Terraform Validate' | ||
uses: hashicorp/terraform-github-actions@master | ||
|
||
- name: Setup Terraform | ||
uses: hashicorp/setup-terraform@v3 | ||
with: | ||
tf_actions_version: ${{ env.TF_VERSION }} | ||
tf_actions_subcommand: 'validate' | ||
tf_actions_working_dir: "./Terraform-AZURE-Services-Creation/AKS" | ||
|
||
- name: 'Terraform Plan' | ||
uses: hashicorp/terraform-github-actions@master | ||
terraform_version: 1.7.4 | ||
terraform_wrapper: true | ||
|
||
- name: Terraform Init | ||
id: init | ||
run: terraform init | ||
env: | ||
ARM_CLIENT_ID: ${{ secrets.AZURE_AD_CLIENT_ID }} | ||
ARM_CLIENT_SECRET: ${{ secrets.AZURE_AD_CLIENT_SECRET }} | ||
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
ARM_TENANT_ID: ${{ secrets.AZURE_AD_TENANT_ID }} | ||
working-directory: "./Terraform-AZURE-Services-Creation/AKS" | ||
|
||
- name: Terraform Fmt | ||
id: fmt | ||
run: terraform fmt | ||
working-directory: "./Terraform-AZURE-Services-Creation/AKS" | ||
|
||
- name: Auto Commit Changes | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
tf_actions_version: ${{ env.TF_VERSION }} | ||
tf_actions_subcommand: 'plan' | ||
tf_actions_working_dir: "./Terraform-AZURE-Services-Creation/AKS" | ||
|
||
- name: Terraform Apply | ||
commit_message: "Terraform fmt" | ||
file_pattern: "*.tf *.tfvars" | ||
commit_user_name: "github-actions[bot]" | ||
|
||
- name: Terraform Plan | ||
id: plan | ||
run: terraform plan -no-color -input=false | ||
env: | ||
ARM_CLIENT_ID: ${{ secrets.AZURE_AD_CLIENT_ID }} | ||
ARM_CLIENT_SECRET: ${{ secrets.AZURE_AD_CLIENT_SECRET }} | ||
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
ARM_TENANT_ID: ${{ secrets.AZURE_AD_TENANT_ID }} | ||
DEPLOYMENT_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
working-directory: "./Terraform-AZURE-Services-Creation/AKS" | ||
continue-on-error: false | ||
|
||
- name: Terraform Apply | ||
id: apply | ||
run: terraform apply -auto-approve -input=false | ||
if: github.ref == 'refs/heads/main' | ||
uses: hashicorp/terraform-github-actions@master | ||
with: | ||
tf_actions_version: ${{ env.TF_VERSION }} | ||
tf_actions_subcommand: 'apply' | ||
tf_actions_working_dir: "./Terraform-AZURE-Services-Creation/AKS" | ||
env: | ||
ARM_CLIENT_ID: ${{ secrets.AZURE_AD_CLIENT_ID }} | ||
ARM_CLIENT_SECRET: ${{ secrets.AZURE_AD_CLIENT_SECRET }} | ||
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
ARM_TENANT_ID: ${{ secrets.AZURE_AD_TENANT_ID }} | ||
working-directory: "./Terraform-AZURE-Services-Creation/AKS" | ||
continue-on-error: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,33 @@ | ||
# Create an Azure VNET | ||
|
||
In this lab you will create a Virtual Network (VNET) that will be used to deploy your AKS instance into | ||
Before proceeding, ensure that the values in the terraform.tfvars file are accurate for your environment. You may need to customize these values to match your specific configuration. | ||
|
||
In this lab you will: | ||
- Create a Virtual Network (VNET) that will be used to deploy your AKS instance into | ||
- Create a Network Security Group (NSG) and assign to the relevant subnets | ||
- Create an Azure Application Gateway for Containers and associate it with the VNET | ||
|
||
## Create the Azure VNET Terraform Configuration | ||
|
||
1. You can find the Terraform configuration for Azure Virtual Network [here](https://github.com/thomast1906/DevOps-The-Hard-Way-Azure/tree/main/Terraform-AZURE-Services-Creation/VNET). The Terraform configuration files are used to create an Azure Vitual Network. | ||
|
||
The Terraform `main.tf` will do a few things: | ||
The Terraform `vnet.tf` will: | ||
- Use a Terraform backend to store the `.tfstate` in an Azure Storage Account | ||
- Use the `azurerm_virtual_network` Terraform resource to create a VNET. | ||
- Use the `azurerm_subnet` Terraform resource to create relevant subnets. | ||
- Use the `uksouth` region, but feel free to change that if you'd like | ||
|
||
2. Create the VNET by running the following: | ||
The Terraform `nsg.tf` will: | ||
- Use the `azurerm_network_security_group` Terraform resource to create a NSG. | ||
- Use the `azurerm_subnet_network_security_group_association` Terraform resource to associate the NSG to the relevant subnets. | ||
|
||
The Terraform `alb.tf` will: | ||
- Use the `azurerm_application_load_balancer` Terraform resource to create an Azure Application Gateway for Containers. | ||
- Use the `azurerm_application_load_balancer_subnet_association` Terraform resource to associate the Azure Application Gateway with the VNET. | ||
- Use the `azurerm_application_load_balancer_frontend` Terraform resource to create a frontend for the Azure Application Gateway. | ||
|
||
|
||
2. Create the VNET, NSG & Azure Application Gateway for Containers by running the following: | ||
- `terraform init` - To initialize the working directory and pull down the provider | ||
- `terraform plan` - To go through a "check" and confirm the configurations are valid | ||
- `terraform apply` - To create the resource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.