|
1 | | -name: Application observability for AWS |
| 1 | +# Example workflow for Claude Code with Amazon Bedrock |
| 2 | +# |
| 3 | +# This workflow demonstrates how to use the Application Observability for AWS action |
| 4 | +# with Claude Code and a custom Bedrock model. |
| 5 | +# |
| 6 | +# Key Features: |
| 7 | +# - Brings your own Bedrock model (pay-per-token usage on your AWS account) |
| 8 | +# - Uses Anthropic's official claude-code-base-action for execution |
| 9 | +# - Two-step process: preparation + execution |
| 10 | +# |
| 11 | +# Prerequisites: |
| 12 | +# 1. AWS IAM role with OIDC trust for GitHub Actions |
| 13 | +# 2. Bedrock InvokeModel permissions in your IAM role |
| 14 | +# 3. Application Signals and CloudWatch permissions |
| 15 | +# |
| 16 | +# Setup: |
| 17 | +# 1. Create repository secret AWSAPM_ROLE_ARN with your IAM role ARN |
| 18 | +# 2. (Optional) Set repository variable AWS_REGION for your preferred region |
| 19 | +# 3. Copy this file to .github/workflows/awsapm.yml in your repository |
| 20 | + |
| 21 | +name: Application observability for AWS (Claude + Bedrock) |
2 | 22 |
|
3 | 23 | on: |
4 | 24 | issue_comment: |
|
8 | 28 |
|
9 | 29 | jobs: |
10 | 30 | awsapm-investigation: |
| 31 | + # Only run when @awsapm is mentioned |
11 | 32 | if: | |
12 | 33 | (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@awsapm')) || |
13 | 34 | (github.event_name == 'issues' && (contains(github.event.issue.body, '@awsapm') || contains(github.event.issue.title, '@awsapm'))) |
14 | 35 | runs-on: ubuntu-latest |
| 36 | + |
15 | 37 | permissions: |
16 | | - contents: write |
17 | | - pull-requests: write |
18 | | - issues: write |
19 | | - id-token: write |
| 38 | + contents: write # To create branches for PRs |
| 39 | + pull-requests: write # To post comments on PRs |
| 40 | + issues: write # To post comments on issues |
| 41 | + id-token: write # Required for AWS OIDC authentication |
| 42 | + |
20 | 43 | steps: |
21 | 44 | - name: Checkout repository |
22 | 45 | uses: actions/checkout@v4 |
23 | | - with: |
24 | | - fetch-depth: 1 |
25 | 46 |
|
26 | 47 | - name: Configure AWS credentials |
27 | 48 | uses: aws-actions/configure-aws-credentials@v4 |
28 | 49 | with: |
29 | | - role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} # this should be the ARN of the IAM role created for Github Actions |
| 50 | + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} |
30 | 51 | aws-region: ${{ vars.AWS_REGION || 'us-east-1' }} |
31 | 52 |
|
32 | | - - name: Run Application observability for AWS Investigation |
33 | | - id: awsapm |
34 | | - uses: mxiamxia/aws-apm-action@main |
| 53 | + # Step 1: Prepare AWS MCP configuration and investigation prompt |
| 54 | + - name: Prepare Investigation Context |
| 55 | + id: prepare |
| 56 | + uses: mxiamxia/aws-apm-action@action-basedline |
| 57 | + with: |
| 58 | + bot_name: "@awsapm" |
| 59 | + cli_tool: "claude_code" |
| 60 | + |
| 61 | + # Step 2: Execute investigation with Claude Code |
| 62 | + - name: Run Claude Investigation |
| 63 | + id: claude |
| 64 | + uses: anthropics/claude-code-base-action@beta |
| 65 | + with: |
| 66 | + use_bedrock: "true" |
| 67 | + model: "us.anthropic.claude-sonnet-4-5-20250929-v1:0" |
| 68 | + prompt_file: ${{ steps.prepare.outputs.prompt_file }} |
| 69 | + mcp_config: ${{ steps.prepare.outputs.mcp_config_file }} |
| 70 | + allowed_tools: ${{ steps.prepare.outputs.allowed_tools }} |
| 71 | + |
| 72 | + # Step 3: Post results back to GitHub issue/PR (reuse the same action) |
| 73 | + - name: Post Investigation Results |
| 74 | + if: always() # Run even if Claude step fails |
| 75 | + uses: mxiamxia/aws-apm-action@action-basedline |
35 | 76 | with: |
36 | 77 | bot_name: "@awsapm" |
| 78 | + cli_tool: "claude_code" |
| 79 | + comment_id: ${{ steps.prepare.outputs.awsapm_comment_id }} |
| 80 | + output_file: ${{ steps.claude.outputs.execution_file }} |
| 81 | + output_status: ${{ steps.claude.outputs.conclusion }} |
0 commit comments