Skip to content

Commit fc5fdde

Browse files
authored
Merge pull request #52 from InbarRose/main
add AWS_ACCESS_KEY_ID to env var checking
2 parents 0d88ce2 + d279faf commit fc5fdde

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ The `check-ecs-exec.sh` found one or more VPC endpoints configured in the VPC fo
126126
The `check-ecs-exec.sh` doesn't support checking this item for shared VPC subnets using [AWS Resouce Access Manager (AWS RAM)](https://aws.amazon.com/ram/). In short, this may not an issue to use ECS Exec if your ECS task VPC doesn't have any VPC endpoint and the task has proper outbound internet connectivity. Make sure to consult your administrator with the official ECS Exec documentation](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-exec.html#ecs-exec-considerations) to find if your VPC need to have an additional VPC endpoint.
127127

128128
19. **🟡 Environment Variables : defined**
129-
SSM uses the AWS SDK which uses the [default chain](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html#credentials-default) when determining authentication. This means if AWS_ACCESS_KEY and AWS_SECRET_ACCESS_KEY are defined in the environment variables and the permissions there do not provide the required permissions for SSM to work, then the execute-command will fail. It is recomended not to define these environment variables.
129+
SSM uses the AWS SDK which uses the [default chain](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html#credentials-default) when determining authentication. This means if AWS_ACCESS_KEY, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY are defined in the environment variables and the permissions there do not provide the required permissions for SSM to work, then the execute-command will fail. It is recomended not to define these environment variables.
130130

131131
## Security
132132

check-ecs-exec.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,8 @@ else
674674
fi
675675
fi
676676

677-
# 11. Check task definition containers for environment variables AWS_ACCESS_KEY and AWS_SECRET_ACCESS_KEY
678-
# if AWS_ACCESS_KEY and AWS_SECRET_ACCESS_KEY are defined in a container, they will be used by the SSM service
677+
# 11. Check task definition containers for environment variables AWS_ACCESS_KEY, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY
678+
# if AWS_ACCESS_KEY, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY are defined in a container, they will be used by the SSM service
679679
# if the key defined does not have requirement permissions, the execute-command will not work.
680680
containerNameList=$(echo "${taskDefJson}" | jq -r ".taskDefinition.containerDefinitions[].name")
681681
idx=0
@@ -686,15 +686,22 @@ for containerName in $containerNameList; do
686686
printf " ${COLOR_DEFAULT}- AWS_ACCESS_KEY"
687687
AWS_ACCESS_KEY_FOUND=$(echo "${taskDefJson}" | jq -r ".taskDefinition.containerDefinitions[${idx}].environment[] | select(.name==\"AWS_ACCESS_KEY\") | .name")
688688
case "${AWS_ACCESS_KEY_FOUND}" in
689-
*AWS_ACCESS_KEY* ) printf ": ${COLOR_YELLOW}defined\n";;
690-
* ) printf ": ${COLOR_GREEN}not defined\n";;
689+
*AWS_ACCESS_KEY* ) printf ": ${COLOR_YELLOW}defined${COLOR_DEFAULT}\n";;
690+
* ) printf ": ${COLOR_GREEN}not defined${COLOR_DEFAULT}\n";;
691691
esac
692+
# find AWS_ACCESS_KEY_ID
693+
printf " ${COLOR_DEFAULT}- AWS_ACCESS_KEY_ID"
694+
AWS_ACCESS_KEY_ID_FOUND=$(echo "${taskDefJson}" | jq -r ".taskDefinition.containerDefinitions[${idx}].environment[] | select(.name==\"AWS_ACCESS_KEY_ID\") | .name")
695+
case "${AWS_ACCESS_KEY_ID_FOUND}" in
696+
*AWS_ACCESS_KEY_ID* ) printf ": ${COLOR_YELLOW}defined${COLOR_DEFAULT}\n";;
697+
* ) printf ": ${COLOR_GREEN}not defined${COLOR_DEFAULT}\n";;
698+
esac
692699
# find AWS_SECRET_ACCESS_KEY
693700
printf " ${COLOR_DEFAULT}- AWS_SECRET_ACCESS_KEY"
694701
AWS_SECRET_ACCESS_KEY_FOUND=$(echo "${taskDefJson}" | jq -r ".taskDefinition.containerDefinitions[${idx}].environment[] | select(.name==\"AWS_SECRET_ACCESS_KEY\") | .name")
695702
case "${AWS_SECRET_ACCESS_KEY_FOUND}" in
696-
*AWS_SECRET_ACCESS_KEY* ) printf ": ${COLOR_YELLOW}defined\n";;
697-
* ) printf ": ${COLOR_GREEN}not defined\n";;
703+
*AWS_SECRET_ACCESS_KEY* ) printf ": ${COLOR_YELLOW}defined${COLOR_DEFAULT}\n";;
704+
* ) printf ": ${COLOR_GREEN}not defined${COLOR_DEFAULT}\n";;
698705
esac
699706
idx=$((idx+1))
700707
done

0 commit comments

Comments
 (0)