Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: windows pipeline: auth to DockerHub to set AWS_FOR_FLUENT_BIT_VERSION… #482

Open
wants to merge 1 commit into
base: mainline
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions scripts/common_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ set_latest_version() {

# Sets AWS_FOR_FLUENT_BIT_VERSION_DOCKERHUB variable with the latest version available in dockerhub.
set_dockerhub_version() {
# Find the dockerhub version.
docker_hub_image_tags=$(curl -s -S 'https://registry.hub.docker.com/v2/repositories/amazon/aws-for-fluent-bit/tags/?page=1&page_size=250' | jq -r '.results[].name')
DOCKER_HUB_SECRET="com.amazonaws.dockerhub.aws-for-fluent-bit.credentials"
username="$(aws secretsmanager get-secret-value --secret-id $DOCKER_HUB_SECRET --region ${1} | jq -r '.SecretString | fromjson.username')"
password="$(aws secretsmanager get-secret-value --secret-id $DOCKER_HUB_SECRET --region ${1} | jq -r '.SecretString | fromjson.password')"
payload="{\"username\": \"${username}\",\"password\": \"${password}\"}"
token=$(curl -s -X POST -H "Content-Type: application/json" -d "${payload}" https://hub.docker.com/v2/users/login | jq -r '.token')
auth="Authorization: Bearer ${token}"
docker_hub_image_tags=$(curl -s -S -H "${auth}" 'https://registry.hub.docker.com/v2/repositories/amazon/aws-for-fluent-bit/tags/?page=1&page_size=250' | jq -r '.results[].name')
tag_array=(`echo ${docker_hub_image_tags}`)
AWS_FOR_FLUENT_BIT_VERSION_DOCKERHUB=$(./get_latest_dockerhub_version.py ${tag_array[@]})
export AWS_FOR_FLUENT_BIT_VERSION_DOCKERHUB
}

# Returns the regional endpoint.
Expand Down Expand Up @@ -133,5 +139,4 @@ compare_image_manifests() {
# Set the required variables
set_all_supported_versions
set_latest_version
set_dockerhub_version
set_stable_version
11 changes: 11 additions & 0 deletions scripts/verify_windows_ssm_parameters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ set -euo pipefail
# Helper methods to verify the SSM Parameter.
#############################################################################################################

# Used to check whether this is being used in the pipeline vs sync tasks
classic_regions_account_id="906394416424"

# Verifies that the given param tag has the expected image in the given region and account.
verify_ssm_param(){
local ssm_parameter region version param_name
Expand Down Expand Up @@ -71,6 +74,14 @@ if [[ $ACTION == "verify-ssm-parameter" ]]; then

# Split the comma separated list of regions into an array
REGIONS=(`echo $REGIONS_TO_PUBLISH | sed 's/,/\n/g'`)

# AWS_FOR_FLUENT_BIT_VERSION_DOCKERHUB is only available if we auth to dockerhub and get it
if [[ "$ACCOUNT_ID" == "${classic_regions_account_id}" ]]; then
set_dockerhub_version "us-west-2"
else
set_dockerhub_version "${REGIONS[0]}"
fi
Comment on lines +79 to +83
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to test that this bit actually works in the windows pipeline. I checked that the script to auth to docker hub works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we will need to clone the docker hub secret to all sync regions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rawahars FYI.


for region in "${REGIONS[@]}"
do
# For a given region, iterate over all supported versions and verify the SSM parameters.
Expand Down