Skip to content

Instantly share code, notes, and snippets.

@albankora
Last active February 16, 2024 09:22
Show Gist options
  • Save albankora/a316d25c9eefd745ec23ad6c395aec2c to your computer and use it in GitHub Desktop.
Save albankora/a316d25c9eefd745ec23ad6c395aec2c to your computer and use it in GitHub Desktop.
Serverless Framework with AWS SSO

Edit config file

vim ~/.aws/config

The config file structure example

[profile dev]
sso_session = dev
sso_account_id = XXXXXXXXXXXX
sso_role_name = AdministratorAccess
region = eu-west-1
output = json

[sso-session dev]
sso_start_url = https://sso-link.awsapps.com/start#
sso_region = eu-west-1
sso_registration_scopes = sso:account:access

PS: The config file has to be updated base on your aws setup

Run aws sso login for the right profile

export AWS_PROFILE=dev && aws sso login --sso-session ${AWS_PROFILE}

Export credentials to bash and update .aws/credentials profile values

eval "$(aws configure export-credentials --profile ${AWS_PROFILE} --format env)" \
&& aws configure set aws_session_token ${AWS_SESSION_TOKEN} --profile ${AWS_PROFILE} \
&& aws configure set aws_access_key_id ${AWS_ACCESS_KEY_ID} --profile ${AWS_PROFILE} \
&& aws configure set aws_secret_access_key ${AWS_SECRET_ACCESS_KEY} --profile ${AWS_PROFILE}

Run the deployment

serverless deploy --stage ${AWS_PROFILE} --verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment