@@ -16,10 +16,18 @@ DISTFILE ?= $(subst /,,$(DESTDIR))/$(subst /,_,$(IMAGE_NAME)).tar.gz
1616UNAME_ARCH = $(shell uname -m)
1717ARCH ?= $(lastword $(subst :, ,$(filter $(UNAME_ARCH ) :% ,x86_64:amd64 aarch64:arm64) ) )
1818
19- .PHONY : all build dist clean
19+ # SSM_AGENT_VERSION is the SSM Agent's distributed RPM Version to install.
20+ SSM_AGENT_VERSION ?= 3.3.1957.0
21+
22+ TEST_ACTIVATION_ID =abcdef12-3456-7890-abcd-ef1234567890
23+ TEST_ACTIVATION_CODE =abcdef1234567890abcdef
24+ TEST_NODE_CERT =test-certificate
25+ TEST_NODE_KEY =test-key
26+
27+ .PHONY : all build dist check check-ssm-agent check-ssm-setup check-iam-ra-setup clean download-ssm-agent update-ssm-agent
2028
2129# Run all build tasks for this container image.
22- all : build
30+ all : build check
2331
2432# Create a distribution container image tarball for release.
2533dist : all
@@ -31,7 +39,65 @@ build:
3139 DOCKER_BUILDKIT=1 docker build $(DOCKER_BUILD_FLAGS ) \
3240 --tag $(IMAGE_NAME ) \
3341 --build-arg IMAGE_VERSION=" $( IMAGE_VERSION) " \
42+ --build-arg SSM_AGENT_VERSION=" $( SSM_AGENT_VERSION) " \
3443 -f Dockerfile . >&2
3544
45+ # Run checks against the bootstrap container image
46+ check : check-ssm-agent check-ssm-setup check-iam-ra-setup
47+
48+ # Check that the SSM Agent is the expected version.
49+ check-ssm-agent :
50+ @echo " Running SSM version check"
51+ @docker run --rm --entrypoint /usr/bin/bash \
52+ $(IMAGE_NAME ) \
53+ -c ' amazon-ssm-agent -version | grep -Fw "$(SSM_AGENT_VERSION)"' >&2
54+
55+ # Check that the SSM setup script doesn't print sensitive input
56+ check-ssm-setup :
57+ @echo " Running SSM setup check"
58+ @OUTPUT=$$(docker run --rm --entrypoint /usr/bin/bash \
59+ $(IMAGE_NAME ) \
60+ -c " eks-hybrid-ssm-setup --region=us-west-2 --activation-id=${TEST_ACTIVATION_ID} --activation-code=${TEST_ACTIVATION_CODE} --enable-credentials-file=true 2>&1 || true" ); \
61+ if echo " $$ OUTPUT" | grep -q " ${TEST_ACTIVATION_ID} " ; then \
62+ echo " Test failed: hybrid activation ID found in output" ; \
63+ exit 1; \
64+ elif echo " $$ OUTPUT" | grep -q " ${TEST_ACTIVATION_CODE} " ; then \
65+ echo " Test failed: hybrid activation code found in output" ; \
66+ exit 1; \
67+ else \
68+ echo " Test passed: No sensitive content in output" ; \
69+ fi
70+
71+ # Check that the IAM-RA setup script doesn't print sensitive input
72+ check-iam-ra-setup :
73+ @echo " Running IAM-RA setup check"
74+ @OUTPUT=$$(docker run --rm --entrypoint /usr/bin/bash \
75+ $(IMAGE_NAME ) \
76+ -c " cp /usr/bin/true /usr/bin/apiclient; eks-hybrid-iam-ra-setup --certificate=${TEST_NODE_CERT} --key=${TEST_NODE_KEY} --dry-run=true 2>&1 || true" ); \
77+ if echo " $$ OUTPUT" | grep -q " ${TEST_NODE_CERT} " ; then \
78+ echo " Test failed: certificate content found in output" ; \
79+ exit 1; \
80+ elif echo " $$ OUTPUT" | grep -q " ${TEST_NODE_KEY} " ; then \
81+ echo " Test failed: private key content found in output" ; \
82+ exit 1; \
83+ else \
84+ echo " Test passed: No sensitive content in output" ; \
85+ fi
86+
87+ # Download SSM Agent version SSM_AGENT_VERSION for all architectures.
88+ download-ssm-agent : amazon-ssm-agent-${SSM_AGENT_VERSION}.amd64.rpm amazon-ssm-agent-${SSM_AGENT_VERSION}.arm64.rpm
89+
90+ amazon-ssm-agent-${SSM_AGENT_VERSION}.amd64.rpm :
91+ curl -L " https://s3.eu-north-1.amazonaws.com/amazon-ssm-eu-north-1/${SSM_AGENT_VERSION} /linux_amd64/amazon-ssm-agent.rpm" \
92+ -o " amazon-ssm-agent-${SSM_AGENT_VERSION} .amd64.rpm"
93+
94+ amazon-ssm-agent-${SSM_AGENT_VERSION}.arm64.rpm :
95+ curl -L " https://s3.eu-north-1.amazonaws.com/amazon-ssm-eu-north-1/${SSM_AGENT_VERSION} /linux_arm64/amazon-ssm-agent.rpm" \
96+ -o " amazon-ssm-agent-${SSM_AGENT_VERSION} .arm64.rpm"
97+
98+ # Update the expected hashes of SSM Agent to those for SSM_AGENT_VERSION.
99+ update-ssm-agent : download-ssm-agent
100+ sha512sum amazon-ssm-agent-${SSM_AGENT_VERSION} .* .rpm > hashes/ssm
101+
36102clean :
37103 rm -f $(DISTFILE )
0 commit comments