version: 0.2 env: variables: # TODO: replace "v0.10.8" with the latest version of infracost CODEBUILD_SRC_DIR: "." INFRACOST_VERSION: "0.10.8" phases: install: commands: #Terraform Install - apt update - apt -y install curl - curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - - apt-add-repository "deb [arch=$(dpkg --print-architecture)] https://apt.releases.hashicorp.com $(lsb_release -cs) main" - apt update - apt -y install terraform=1.3.6 # Install Infracost # - "curl -fsSL https://raw.githubusercontent.com/infracost/infracost/master/scripts/install.sh | sh" # - env - wget https://github.com/infracost/infracost/releases/download/v0.10.18/infracost-linux-amd64.tar.gz - tar xzf infracost-linux-amd64.tar.gz -C /tmp - mv /tmp/infracost-linux-amd64 /usr/local/bin/infracost # Check th infracost version - "infracost --version" # Enter the terraform directory - "cd $CODEBUILD_SRC_DIR/db-provisioning/db-provisioning-code" # Run the infracost for resource estimation - apikey=`aws secretsmanager get-secret-value --secret-id="tf/infracost/apikey" --query='SecretString' --output=text --region us-east-1 |jq -r .tf_infracost_apikey` - export INFRACOST_API_KEY=$apikey - "infracost breakdown --path ." pre_build: commands: - "infracost breakdown --path . > Infracost_report.xml"