Skip to content

Commit

Permalink
removed cross account requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgreen-moj committed Nov 14, 2023
1 parent 15a5cb1 commit ed61906
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 206 deletions.
18 changes: 1 addition & 17 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 52 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,73 @@
-include .env
export

deploy:
./scripts/deploy.sh

uninstall:
./scripts/uninstall_all_deployments.sh

fmt:
terraform fmt --recursive
aws-vault exec $$AWS_VAULT_PROFILE -- terraform fmt --recursive

init:
terraform init -upgrade -reconfigure \
--backend-config="key=terraform.production.state"
aws-vault exec $$AWS_VAULT_PROFILE -- terraform init -reconfigure \
--backend-config="key=terraform.$$ENV.state"

init-upgrade:
aws-vault exec $$AWS_VAULT_PROFILE -- terraform init -upgrade \
--backend-config="key=terraform.$$ENV.state"

# How to use
# IMPORT_ARGUMENT=module.foo.bar some_resource make import
import:
aws-vault exec $$AWS_VAULT_PROFILE -- terraform import $$IMPORT_ARGUMENT

workspace-list:
aws-vault exec $$AWS_VAULT_PROFILE -- terraform workspace list

workspace-select:
aws-vault exec $$AWS_VAULT_PROFILE -- terraform workspace select $$ENV || \
aws-vault exec $$AWS_VAULT_PROFILE -- terraform workspace new $$ENV

validate:
terraform validate
aws-vault exec $$AWS_VAULT_PROFILE -- terraform validate

plan-out:
aws-vault exec $$AWS_VAULT_PROFILE -- terraform plan -no-color > $$ENV.tfplan

plan:
terraform plan
aws-vault exec $$AWS_VAULT_PROFILE -- terraform plan

refresh:
aws-vault exec $$AWS_VAULT_PROFILE -- terraform refresh

output:
aws-vault exec $$AWS_VAULT_PROFILE -- terraform output -json

apply:
terraform apply
aws-vault exec $$AWS_VAULT_PROFILE -- terraform apply
./scripts/publish_terraform_outputs.sh

deploy:
./scripts/deploy.sh
state-list:
aws-vault exec $$AWS_VAULT_PROFILE -- terraform state list

uninstall:
./scripts/uninstall_all_deployments.sh
show:
aws-vault exec $$AWS_VAULT_PROFILE -- terraform show -no-color

destroy:
terraform destroy
aws-vault exec $$AWS_VAULT_PROFILE -- terraform destroy

clean:
rm -rf .terraform/ terraform.tfstate*

tfenv:
tfenv use $(cat versions.tf 2> /dev/null | grep required_version | cut -d "\"" -f 2 | cut -d " " -f 2) && tfenv pin

generate_diagrams:
docker run -it --rm -v "${PWD}":/app/ -w /app/documentation/diagrams/ mjdk/diagrams scripts/architecture_diagram.py
docker run -it --rm -v "${PWD}":/app/ -w /app/documentation/diagrams/ mjdk/diagrams scripts/detailed_eks_diagram.py

.PHONY: init validate plan apply deploy uninstall destroy

.PHONY:
fmt init workspace-list workspace-select validate plan-out plan \
refresh output apply state-list show destroy clean tfenv
24 changes: 3 additions & 21 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,6 @@ provider "aws" {
}
}

provider "aws" {
region = var.aws_region
alias = "development"

assume_role {
role_arn = var.assume_role_development
}
}

provider "aws" {
region = var.aws_region
alias = "pre_production"

assume_role {
role_arn = var.assume_role_pre_production
}
}

data "aws_availability_zones" "available_zones" {
count = var.enabled ? 1 : 0
state = "available"
Expand Down Expand Up @@ -90,8 +72,8 @@ module "eks" {
tags = module.eks_label.tags

providers = {
aws = aws.main
aws.development = aws.development
aws.pre_production = aws.pre_production
aws = aws.main
# aws.development = aws.development
# aws.pre_production = aws.pre_production
}
}
Loading

0 comments on commit ed61906

Please sign in to comment.