Reputation: 1604
I have the following Dockerfile
FROM public.ecr.aws/docker/library/python:3.7-slim-buster as base
WORKDIR /code
RUN apt-get update -y && \
pip install --upgrade pip && \
mkdir ~/.aws \
&& touch ~/.aws/credentials
RUN apt-get install -y nodejs npm awscli jq
Which is base from slim-buster.
I am trying to do a one command aws sts
command from this recommended AWS sts assume role in one command solution
However the the eval solution is coming up "blank" or the parenthesis is not escaped properly within a make command:
sts-qa:
eval $(aws sts assume-role --role-arn arn:aws:iam::1234556778:role/aws-role --role-session-name pebble | jq -r '.Credentials | "export AWS_ACCESS_KEY_ID=\(.AccessKeyId)\n export AWS_SECRET_ACCESS_KEY=\(.SecretAccessKey)\nexport AWS_SESSION_TOKEN=\(.SessionToken)\n"')
the error I get is:
root@b79fd0ebf8cf:/code# make sts-qa
eval \n export AWS_SECRET_ACCESS_KEY=\(.SecretAccessKey)\n export AWS_SESSION_TOKEN=\(.SessionToken)\n"')
/bin/sh: 1: Syntax error: ")" unexpected
I have tried:
/bin/sh: 2: Syntax error: Unterminated quoted string
eval
(the
entire bash command is blankI have ran out of ideas
Upvotes: 0
Views: 146
Reputation: 530833
$(...)
is Makefile syntax for expanding a variable name, so the (
is closed by the first unescaped )
in the command you want to execute. You need to double the $
to have it be treated literally.
sts-qa:
eval $$(aws sts assume-role --role-arn arn:aws:iam::1234556778:role/aws-role --role-session-name pebble | jq -r '.Credentials | "export AWS_ACCESS_KEY_ID=\(.AccessKeyId)\n export AWS_SECRET_ACCESS_KEY=\(.SecretAccessKey)\nexport AWS_SESSION_TOKEN=\(.SessionToken)\n"')
Upvotes: 2