Sign inSign up

254in61/cloud-infra-dev-env

By 254in61

Updated over 1 year ago

Container image for cloud infra development

Image
0

1.2K

254in61/cloud-infra-dev-env repository overview

Objective

Ensuring I don't have to be installing Terraform environments all the time.

I decided to build a container, based on Ubuntu that I will always use for my cloud platform builds.

About container image

Uses ubuntu:latest as the base image. curl, unzip, gnupg, and other essential dependencies. Terraform. Terragrunt. tf-switcher (TFSwitch). TFlint. checkov. AWS CLI. Azure CLI. Python and boto3. Sets /workspace as the working directory. Sets the default command to /bin/bash.

docker image build & run container

build image from Dockerfile

$ podman build -t cloud-infra-dev-env .

run container from the image. $ ~/developer/tools/container-start.sh docker.io/254in61/cloud-infra-dev-env cloud-infra-dev-env

pull repos and deploy

  • Get into container and do git clone.
  • Git credentials might need to be saved.

AWS infra

  • Containers have /root/ as the home dir.
  • In this case, our container already has AWS CLI installed.. So, you just need to configure the credentials
  • Safest way to pass aws credentials is AWS_PROFILE passed from the local machine to the container as the container starts $ podman run -e AWS_PROFILE=my-profile -v ~/.aws:/root/.aws -it your-container-name $ podman run -e AWS_PROFILE=ust-aws-lab -v ~/secrets/.aws:/root/.aws -it --name cloud-dev-env --restart=always docker.io/254in61/cloud-infra-dev-env bash

Explanation: podman run: Starts a new container. -i: Interactive mode (keeps STDIN open). -t: Allocates a TTY (for Bash). --name my-container: Assigns a custom name (my-container). --restart=always: Ensures the container restarts automatically after a reboot or crash. bash: Launches a Bash shell inside the container.

Azure infra

  1. Verify the Azure cli installation: $ az --version

  2. Log into Azure: $ az login To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code ****** to authenticate.

    The browser will confirm your sign in and then your CLI will grt through

  3. Random az cli cmds : a) List all resources in a subscription : $ az resource list --output table

b)If you want them in a JSON format : $ az resource list --output json

c) listing resources in a specific resource group: $ az resource list --resource-group --output table $ az resource list --resource-group alpha-resource-group --output table

d) list vms : $ az vm list --output table

  1. Terraform needs an 'Azure Service Principal' to authenticate. Run: az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/"

    $ az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/-*****--*****"

    This will return:

{ "appId": "", "displayName": "", "password": "", "tenant": "" }

Save these securely, as they are needed in Terraform.

It will be added in your provider.tf file :

provider "azurerm" { features {}

subscription_id = "<your-subscription-id>"
client_id       = "<your-client-id>"
client_secret   = "<your-client-secret>"
tenant_id       = "<your-tenant-id>"

}

Create terraform files in your repo and run as terraform from there.

Tag summary

Content type

Image

Digest

sha256:52a4f76b9

Size

801.9 MB

Last updated

over 1 year ago

docker pull 254in61/cloud-infra-dev-env