broad-zoo-34077
07/14/2022, 1:45 PMwhite-airport-8778
busy-agent-35515
07/14/2022, 2:14 PM--commit=$GITHUB_SHA
env var as the commit IDnice-morning-3455
07/14/2022, 2:15 PMRun infracost/actions/setup@v1
with:
api-key: ***
version: 0.9.x
currency: USD
github-token: ***
env:
TFPath: Azure/
TF_VAR_PREFIX: JBI-IAC-DEMO
TF_VAR_LOCATION: westeurope
TF_VAR_USERNAME: azureuser
TF_VAR_PASSWORD: ***
TF_VAR_FLEXVM_API_USERNAME: ***
TF_VAR_FLEXVM_API_PASSWORD: ***
TF_VAR_FLEXVM_PROGRAM_SERIAL: ***
TF_VAR_FLEXVM_CONFIG_NAME: ***
TF_VAR_FLEXVM_VM_SERIAL: ***
ARM_CLIENT_ID: ***
ARM_CLIENT_SECRET: ***
ARM_SUBSCRIPTION_ID: ***
ARM_TENANT_ID: ***
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/work/_temp/063842bf-6bae-40b3-bc5d-bb8e80d67c23 -f /home/runner/work/_temp/b1c8b699-def9-4440-8075-13000e7a985c
Setup Infracost CLI version 0.9.24
/home/runner/work/_temp/063842bf-6bae-40b3-bc5d-bb8e80d67c23/infracost configure set api_key ***
/home/runner/work/_temp/063842bf-6bae-40b3-bc5d-bb8e80d67c23/infracost configure set currency USD
The calculation:
Run infracost breakdown --path plan.json --format json --usage-file infracost-usage.yml --out-file /tmp/infracost.json
infracost breakdown --path plan.json --format json --usage-file infracost-usage.yml --out-file /tmp/infracost.json
shell: /usr/bin/bash -e {0}
env:
TFPath: Azure/
TF_VAR_PREFIX: JBI-IAC-DEMO
TF_VAR_LOCATION: westeurope
TF_VAR_USERNAME: azureuser
TF_VAR_PASSWORD: ***
TF_VAR_FLEXVM_API_USERNAME: ***
TF_VAR_FLEXVM_API_PASSWORD: ***
TF_VAR_FLEXVM_PROGRAM_SERIAL: ***
TF_VAR_FLEXVM_CONFIG_NAME: ***
TF_VAR_FLEXVM_VM_SERIAL: ***
ARM_CLIENT_ID: ***
ARM_CLIENT_SECRET: ***
ARM_SUBSCRIPTION_ID: ***
ARM_TENANT_ID: ***
INFRACOST_GITHUB_ACTION: true
INFRACOST_SKIP_UPDATE_CHECK: true
INFRACOST_VCS_REPOSITORY_URL: <https://github.com/jbismans/github-actions-infra-as-code-demo>
INFRACOST_LOG_LEVEL: info
time="2022-07-14T14:05:31Z" level=info msg="Detected Terraform plan JSON file at plan.json"
time="2022-07-14T14:05:31Z" level=info msg="Starting: Extracting only cost-related params from terraform"
time="2022-07-14T14:05:31Z" level=info msg="Starting: Retrieving cloud prices to calculate costs"
time="2022-07-14T14:05:31Z" level=warning msg="Multiple products with prices found for azurerm_virtual_machine.lnxvm Instance usage (pay as you go, Standard_B1s), using the first product"
time="2022-07-14T14:05:31Z" level=warning msg="Multiple products with prices found for azurerm_virtual_machine.lnxvm Instance usage (pay as you go, Standard_B1s), using the first product"
time="2022-07-14T14:05:31Z" level=info msg="Output saved to /tmp/infracost.json"
The post
Run infracost/actions/comment@v1
with:
path: /tmp/infracost.json
behavior: update
github-token: ***
env:
TFPath: Azure/
TF_VAR_PREFIX: JBI-IAC-DEMO
TF_VAR_LOCATION: westeurope
TF_VAR_USERNAME: azureuser
TF_VAR_PASSWORD: ***
TF_VAR_FLEXVM_API_USERNAME: ***
TF_VAR_FLEXVM_API_PASSWORD: ***
TF_VAR_FLEXVM_PROGRAM_SERIAL: ***
TF_VAR_FLEXVM_CONFIG_NAME: ***
TF_VAR_FLEXVM_VM_SERIAL: ***
ARM_CLIENT_ID: ***
ARM_CLIENT_SECRET: ***
ARM_SUBSCRIPTION_ID: ***
ARM_TENANT_ID: ***
INFRACOST_GITHUB_ACTION: true
INFRACOST_SKIP_UPDATE_CHECK: true
INFRACOST_VCS_REPOSITORY_URL: <https://github.com/jbismans/github-actions-infra-as-code-demo>
INFRACOST_LOG_LEVEL: info
No errors I'm afraid.
However, you are mentioning this github token and I must admit, I'm seeing a mention of it in the code:
uses: actions/github-script@0.9.0
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }} #Variable needs to be fixed?
script: |
const output = `#### Terraform Format and Style đź–Ś\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\`
#### Terraform Plan đź“–\`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${process.env.PLAN}
\`\`\`
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
I haven't created the token in my secrets because I wasn't sure if it was a real Github API token and what access rights would be needed. And after some googling, I thought it was some intrinsic to github https://docs.github.com/en/actions/security-guides/automatic-token-authentication which doesn't need you to create something.busy-agent-35515
07/14/2022, 2:19 PMinfracost/actions/setup@v2
busy-agent-35515
07/14/2022, 2:22 PMbusy-agent-35515
07/14/2022, 2:24 PMnice-morning-3455
07/14/2022, 2:25 PMProject Previous New Diff
jbismans/github-actions-infra-as-code-demo/Azure/plan.json $97.95 $180 +$82.49 (+84%)
Infracost output
Project: jbismans/github-actions-infra-as-code-demo/Azure/plan.json
~ azurerm_virtual_machine.fgtvm
+$82.49 ($84.00 → $166)
~ Instance usage (pay as you go, Standard_F2s → Standard_F4s)
+$82.49 ($83.22 → $166)
Monthly cost change for jbismans/github-actions-infra-as-code-demo/Azure/plan.json
Amount: +$82.49 ($97.95 → $180)
Percent: +84%
busy-agent-35515
07/14/2022, 2:25 PMwhite-airport-8778
nice-morning-3455
07/14/2022, 2:39 PMwhite-airport-8778