-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (72 loc) · 2.43 KB
/
Makefile
File metadata and controls
85 lines (72 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
AWS_PROFILE=grassland
AWS_PATH=$(HOME)/.aws
AWS_FILE=$(AWS_PATH)/config
.PHONY all:
all: .check-all dev-console-build dev-console-run
.PHONY dev-console-run: dev-console-build
dev-console-run: .check-all
docker run \
--rm \
-ti \
-v $(HOME)/.aws:/root/.aws:rw \
-v ~/.ssh/aws:/root/.ssh \
-v ~/.kube:/root/.kube \
-v ~/.gitconfig:/root/.gitconfig \
dev-console \
/bin/bash
.PHONY dev-console-build:
dev-console-build:
docker build \
--rm \
-t dev-console \
.
.PHONY dev-console-clean:
dev-console-clean:
docker rmi dev-console
.PHONY .check-all:
.check-all: aws-check
.PHONY aws-check:
aws-check:
# Very important note... a conditional within a target must not begin with a \t character, but commands within it must
ifeq ($(shell test -f "$(AWS_FILE)"; echo $$?),1)
$(error "$(AWS_FILE)" was not found. Please run make aws-init")
else
$(info Using environment file "$(AWS_FILE)")
endif
# executes if the path does not exist
$(AWS_PATH):
mkdir -p "$(AWS_PATH)"
# executes if the file does not exist
$(AWS_FILE):
@echo "Creating $(AWS_FILE)"
@touch "$(AWS_FILE)"
.PHONY aws-init:
aws-init: $(AWS_PATH) $(AWS_FILE)
# Very important note... a conditional within a target must not begin with a \t character, but commands within it must
# If the aws profile is not found, then add it to the file
ifeq ($(shell grep -c "\[profile $(AWS_PROFILE)\]" "$(AWS_FILE)"),0)
@echo "Adding [profile $(AWS_PROFILE)] to \"$(AWS_FILE)\""
@echo "" >> "$(AWS_FILE)"
@echo "[profile $(AWS_PROFILE)]" >> "$(AWS_FILE)"
@echo "sso_start_url = https://d-9d672f4202.awsapps.com/start" >> "$(AWS_FILE)"
@echo "sso_region = ca-central-1" >> "$(AWS_FILE)"
@echo "region = ca-central-1" >> "$(AWS_FILE)"
@echo "sso_account_id = 932200675199" >> "$(AWS_FILE)"
@echo "sso_role_name = AWSAdministratorAccess" >> "$(AWS_FILE)"
else
@echo "Found an existing AWS Profile \"$(AWS_PROFILE)\" in \"$(AWS_FILE)\""
endif
# executes if the path does not exist
$(ENV_PATH):
mkdir -p "$(ENV_PATH)"
# executes if the file does not exist
$(ENV_FILE):
@echo "Creating $(ENV_FILE)"
@echo "AWS_USER=$(USER)" > "$(ENV_FILE)"
@echo "AWS_PROFILE=$(AWS_PROFILE)" >> "$(ENV_FILE)"
@read -p "Developer Specific AWS IP: " answer; echo "AWS_IP=$$answer" >> $(ENV_FILE)
@read -p "Developer Specific AWS PORT: " answer; echo "AWS_PORT=$$answer" >> $(ENV_FILE)
@cat "$(ENV_FILE)"
# runs the directory creation and file creation targets
.PHONY env-init:
env-init: $(ENV_PATH) $(ENV_FILE)