|
| 1 | +--- |
| 2 | +name: 'Powerpipe Workflow' |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + cloud_provider: |
| 8 | + description: 'Cloud Provider Name. i.g. AWS, Azure, GCP, OCI' |
| 9 | + required: true |
| 10 | + type: string |
| 11 | + default: 'AWS' |
| 12 | + mod_url: |
| 13 | + description: 'Powerpipe Mod URL. Get URL from here: https://hub.powerpipe.io/' |
| 14 | + required: false |
| 15 | + type: string |
| 16 | + default: 'https://github.com/turbot/steampipe-mod-aws-thrifty' |
| 17 | + plugin_connection: |
| 18 | + description: 'Powerpipe plugin-connection to establish the connection between powerpipe and plugin.' |
| 19 | + required: false |
| 20 | + type: string |
| 21 | + default: | |
| 22 | + connection "aws" { |
| 23 | + plugin = "aws" |
| 24 | + } |
| 25 | + controls: |
| 26 | + description: 'Controlers to run in powerpipe' |
| 27 | + required: false |
| 28 | + type: string |
| 29 | + benchmarks: |
| 30 | + description: 'Powerpipe step benchmarks to scan in specific mod.' |
| 31 | + required: false |
| 32 | + type: string |
| 33 | + default: | |
| 34 | + all |
| 35 | +
|
| 36 | + # GCP Authentication |
| 37 | + create_credentials_file: |
| 38 | + required: false |
| 39 | + type: string |
| 40 | + default: true |
| 41 | + description: 'If true, the action will securely generate a credentials file which can be used for authentication via gcloud and Google Cloud SDKs.' |
| 42 | + token_format: |
| 43 | + required: false |
| 44 | + type: string |
| 45 | + default: access_token |
| 46 | + description: 'Output format for the generated authentication token. For OAuth 2.0 access tokens, specify "access_token". For OIDC tokens, specify "id_token". To skip token generation, leave this value empty' |
| 47 | + access_token_lifetime: |
| 48 | + required: false |
| 49 | + type: string |
| 50 | + default: 300s |
| 51 | + description: 'Desired lifetime duration of the access token, in seconds' |
| 52 | + project_id: |
| 53 | + required: false |
| 54 | + type: string |
| 55 | + description: 'ID of the default project to use for future API calls and invocations.' |
| 56 | + |
| 57 | + secrets: |
| 58 | + TOKEN: |
| 59 | + description: 'GitHub Token' |
| 60 | + required: false |
| 61 | + |
| 62 | + # AWS Authentication |
| 63 | + aws_assume_role: |
| 64 | + description: 'AWS IAM role to assume. Necessary if cloud_provider is AWS.' |
| 65 | + required: false |
| 66 | + |
| 67 | + # Azure Authentication |
| 68 | + AZURE_CLIENT_ID: |
| 69 | + description: 'Client ID of Azure cloud OIDC.' |
| 70 | + required: false |
| 71 | + AZURE_TENANT_ID: |
| 72 | + description: 'Tenant ID of aure cloud OIDC.' |
| 73 | + required: false |
| 74 | + SUBSCRIPTION_ID: |
| 75 | + description: 'Subscript ID of Azure Cloud OIDC.' |
| 76 | + required: false |
| 77 | + |
| 78 | + # GCP Authentication |
| 79 | + GCP_CREDENTIALS: |
| 80 | + description: 'The Google Cloud JSON service account key to use for authentication' |
| 81 | + required: false |
| 82 | + WORKLOAD_IDENTITY_PROVIDER: |
| 83 | + required: false |
| 84 | + description: 'The full identifier of the Workload Identity Provider' |
| 85 | + SERVICE_ACCOUNT: |
| 86 | + required: false |
| 87 | + description: 'The service account to be used' |
| 88 | + |
| 89 | +jobs: |
| 90 | + powerpipe: |
| 91 | + name: 'Powerpipe Shared Workflow' |
| 92 | + runs-on: ubuntu-latest |
| 93 | + steps: |
| 94 | + - name: Checkout repo |
| 95 | + uses: actions/checkout@v4 |
| 96 | + |
| 97 | + - name: Setup AWS Credentials |
| 98 | + uses: aws-actions/configure-aws-credentials@v4 |
| 99 | + with: |
| 100 | + role-to-assume: ${{ secrets.aws_assume_role }} |
| 101 | + role-session-name: powerpipe |
| 102 | + aws-region: us-east-1 |
| 103 | + if: ${{ inputs.cloud_provider == 'AWS' }} |
| 104 | + |
| 105 | + - name: 'Authenticate to Google Cloud' |
| 106 | + uses: 'google-github-actions/auth@v2' |
| 107 | + with: |
| 108 | + credentials_json: '${{ secrets.GCP_CREDENTIALS }}' |
| 109 | + create_credentials_file: ${{ inputs.create_credentials_file }} |
| 110 | + token_format: ${{ inputs.token_format }} |
| 111 | + workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} |
| 112 | + service_account: ${{ secrets.SERVICE_ACCOUNT }} |
| 113 | + access_token_lifetime: ${{ inputs.access_token_lifetime }} |
| 114 | + project_id: ${{ inputs.project_id }} |
| 115 | + if: ${{ inputs.cloud_provider == 'GCP' }} |
| 116 | + |
| 117 | + - name: Authenticate to Azure Cloud |
| 118 | + uses: azure/login@v1 |
| 119 | + with: |
| 120 | + client-id: ${{ secrets.AZURE_CLIENT_ID }} |
| 121 | + tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
| 122 | + subscription-id: ${{ secrets.SUBSCRIPTION_ID }} |
| 123 | + if: ${{ inputs.cloud_provider == 'AZURE' }} |
| 124 | + |
| 125 | + - name: Setup Steampipe |
| 126 | + uses: turbot/steampipe-action-setup@v1 |
| 127 | + with: |
| 128 | + plugin-connections: ${{ inputs.plugin_connection }} |
| 129 | + |
| 130 | + - name: Install Powerpipe |
| 131 | + uses: turbot/powerpipe-action-setup@v1 |
| 132 | + |
| 133 | + - name: Start steampipe service |
| 134 | + run: | |
| 135 | + steampipe service start |
| 136 | +
|
| 137 | + - name: Run Terraform AWS Compliance control |
| 138 | + uses: turbot/powerpipe-action-check@v1 |
| 139 | + with: |
| 140 | + mod-url: ${{ inputs.mod_url }} |
| 141 | + controls: ${{ inputs.controls }} |
| 142 | + benchmarks: ${{ inputs.benchmarks }} |
| 143 | + github-token: ${{ secrets.TOKEN }} |
| 144 | + |
| 145 | + - name: Read generated markdown file |
| 146 | + id: read_md_file |
| 147 | + run: | |
| 148 | + # Read the content of the generated .md file into an environment variable |
| 149 | + FILE_PATH="${{ github.workspace }}/*.md" |
| 150 | + MD_CONTENT=$(cat $FILE_PATH) |
| 151 | + echo "md_content<<EOF" >> $GITHUB_ENV |
| 152 | + echo "$MD_CONTENT" >> $GITHUB_ENV |
| 153 | + echo "EOF" >> $GITHUB_ENV |
| 154 | +
|
| 155 | + - name: Comment on the PR with the markdown report |
| 156 | + uses: peter-evans/create-or-update-comment@v3 |
| 157 | + with: |
| 158 | + token: ${{ secrets.TOKEN }} |
| 159 | + issue-number: ${{ github.event.pull_request.number }} |
| 160 | + body: | |
| 161 | + ## Terraform Compliance Report |
| 162 | + ${{ env.md_content }} |
| 163 | + continue-on-error: true |
| 164 | +... |
0 commit comments