I'm working with a tool called dbt
and the database authentication method for the tool utilizes IAM. Unfortunately, IAM profiles do not exist when CodeBuild projects are built because it utilizes Instance Profiles instead. Beacause of this I am unable to connect to my database.
Referencing this question, I tried running aws sts get-caller-identity
in the project to see if I was able to get some of the values I need returned, but it returned
botocore.exceptions.ProfileNotFound: The config profile (***) could not be found
Does anyone have idea on how to generate my own ~/.aws/config
within a CodeBuild project?
edit: the tool uses boto3 to generate temporary credentials here: https://github.com/fishtown-analytics/dbt/blob/9d00c000720d17c42a4fa08a26b75bd500cc857f/plugins/redshift/dbt/adapters/redshift/connections.py#L101-L123
but it does not seem to be able to generate those credentials within a CodeBuild project.
edit:
buildspec.yml
version: 0.2
env:
variables:
MODELS_REPO: dbt-dev
PYTHON_VERSION: 3.8
parameter-store:
AWS_ENVIRONMENT: "/cloudformation/environment"
AWS_PROFILE: "/cloudformation/environment"
CODEARTIFACT_COMPANY: "/codeartifact/company"
GITHUB_OWNER: "/github/owner"
GITHUB_PERSONAL_ACCESS_TOKEN: "/secret/github/token"
GITHUB_USER: "/github/user"
phases:
install:
runtime-versions:
python: "${PYTHON_VERSION}"
commands:
- pip install -r projects/${PROJECT_NAME}/requirements.txt
- ./projects/${PROJECT_NAME}/.aws/phases/install.sh
pre_build:
commands:
- ./projects/${PROJECT_NAME}/.aws/phases/pre_build.sh
build:
commands:
- ./projects/${PROJECT_NAME}/.aws/phases/build.sh
post_build:
commands:
- ./projects/${PROJECT_NAME}/.aws/phases/post_build.sh
cache:
paths:
- /root/.cache/pip
- /root/.cache/pip/**/*
- ~/.cache/pip
- ~/.cache/pip/**/*