I want to trigger the AWS backup service whenever the Bitbucket pipeline runs and i am using Open ID connect and it works well for deployment on S3 and Elastic Beanstalk as the backend
currently, I am using the same IAM Role: AWS_OIDC_ROLE_ARN to trigger the AWS Backup service and also created a lambda function to trigger the AWS backup service when Bitbucket triggers lambda,.
Both approaches got the same error
<span>Parameter validation failed:</span>
<span>Invalid length for parameter WebIdentityToken, value: 1, valid min length: 4</span> and it's due to the Open ID connect approach, how to resolve this issue
here is my script
pipelines:
default:
- step:
name: Install AWS CLI v2 and Invoke Lambda
image: node:16
script:
- curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
- unzip awscliv2.zip
- ./aws/install
- aws --version
# Set up the environment for Lambda invocation
- export AWS_REGION=ca-central-1
- export AWS_ROLE_ARN=arn:aws:iam::468973563763:role/BitBucket-access-Role-EB-deploy
- export AWS_WEB_IDENTITY_TOKEN_FILE=$(pwd)/web-identity-token
- echo $BITBUCKET_STEP_OIDC_TOKEN > $AWS_WEB_IDENTITY_TOKEN_FILE
- echo "$BITBUCKET_STEP_OIDC_TOKEN" | wc -m
- echo "$BITBUCKET_STEP_OIDC_TOKEN" > $AWS_WEB_IDENTITY_TOKEN_FILE
- cat $AWS_WEB_IDENTITY_TOKEN_FILE # Check the content of the token
- cat $AWS_WEB_IDENTITY_TOKEN_FILE # Check the content of the token
- unset AWS_ACCESS_KEY_ID
- unset AWS_SECRET_ACCESS_KEY
# Invoke the Lambda function
- aws lambda invoke --function-name Custom_RDS_Backup_using_AWS_CODEPIPELINE --invocation-type Event --payload '{"key":"value"}' --region $AWS_REGION response.json