I want to deploy cloudformation template in Account 2 from Account 1 by assuming role in Account 2. Assume role script is running fine but while trying to deploy cloud formation template it gives below error.
An HTTP Client raised an unhandled exception: Invalid header value.
Script for assuming role:
#!/bin/bash
set -x
CREDS=$(aws sts assume-role \
--role-arn $CROSS_ACCOUNT_ROLE \
--role-session-name $(date '+%Y%m%d%H%M%S%3N') \
--duration-seconds 3600 \
--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' \
--output text)
echo $CREDS
export AWS_DEFAULT_REGION="us-east-1"
export AWS_ACCESS_KEY_ID=$(echo $CREDS | cut -d' ' -f1)
export AWS_SECRET_ACCESS_KEY=$(echo $CREDS | cut -d' ' -f2)
export AWS_SESSION_TOKEN=$(echo $CREDS | cut -d' ' -f3)
This script is run by code-build service. After this script code build runs aws cloudformation deploy command.