This repository contains a Terraform configuration to deploy a Docker container on Azure. The configuration creates an Azure Resource Group, an Azure Container Group, and deploys a specified Docker image into the container group.
Ensure you have the following installed before proceeding:
-
Clone this repository to your local machine:
git clone https://github.com/dinethsiriwardana/Terraform-configuration-to-deploy-an-Azure-Web-App-with-GitHub.git cd Terraform-configuration-to-deploy-an-Azure-Web-App-with-GitHub
-
Update the variables in the
terraform.tfvars
file or pass them during runtime:subscription_id = "<your_azure_subscription_id>"
-
Replace the Docker image in the Terraform configuration with your image:
image = "dinethsiriwardana/slcitiesfront:latest"
-
Authenticate with Azure:
az login
-
Initialize Terraform:
terraform init
-
Validate the configuration (optional):
terraform validate
-
Apply the Terraform configuration:
terraform apply
Provide the necessary input for the variable
subscription_id
if not set interraform.tfvars
. -
Confirm the deployment when prompted.
After successful deployment, Terraform will output:
container_ip_address
: The public IP address of the container group.container_fqdn
: The Fully Qualified Domain Name (FQDN) of the container group.
To destroy the resources created by this Terraform configuration, run:
terraform destroy
This configuration uses the following Terraform provider:
- AzureRM:
azurerm = { source = "hashicorp/azurerm" version = "4.15.0" }
-
Azure Resource Group:
- Name:
docker-container-rg
- Location:
East US
- Name:
-
Azure Container Group:
- Name:
docker-container-group
- DNS Name Label:
myapp-container-az-tf-mschamps
- OS Type:
Linux
- Public IP Address
- Docker Image:
dinethsiriwardana/slcitiesfront:latest
- Name:
- Environment:
dev
This project is licensed under the MIT License. See the LICENSE
file for details.