This repository contains Terraform code to provision an Amazon Elastic Container Registry (ECR) repository named "helloworldapp" in the specified AWS region. The repository is intended to host the Docker images for the "Hello World" application.
Before you begin, ensure you have the following:
- AWS access key and secret key with appropriate permissions.
- Terraform installed on your local machine.
- AWS CLI configured with appropriate access credentials.
- Clone this repository to your local machine.
- Ensure you have fulfilled all prerequisites mentioned above.
- Navigate to the directory containing the Terraform configuration file (
main.tf).
- Open the
main.tffile. - Ensure that the variables
AWS_ACCESS_KEYandAWS_SECRET_KEYare populated with your AWS access key and secret key. - Optionally, you can modify the default value of the
AWS_REGIONvariable if you wish to deploy the ECR repository in a different AWS region.
-
Initialize Terraform by running the following command:
terraform init
-
Validate the Terraform configuration:
terraform validate
-
Preview the changes that Terraform will make:
terraform plan
-
Apply the Terraform configuration to create the ECR repository:
terraform apply
Upon successful execution, Terraform will output the URL of the newly created ECR repository:
terraform helloworldapp-repository-URL = <repository_url>
You can now push Docker images to the ECR repository using the provided URL.
To remove the provisioned resources and destroy the ECR repository, run:
terraform destroy
- Ensure that you handle AWS access keys and secret keys securely.
- Make sure to follow AWS best practices for security and access management.
- For production environments, consider incorporating this Terraform configuration into a CI/CD pipeline for automated deployments.
For more information on AWS ECR repositories and Terraform, refer to the AWS ECR documentation and Terraform documentation respectively.