Skip to content

New resource: aws_bedrockagent_flow #42201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 56 commits into
base: main
Choose a base branch
from

Conversation

delamarch3
Copy link
Contributor

Description

This implements the resource for AWS Bedrock Flows.

Relations

Closes #41353

References

AWS - Flows User Guide
awscli - create-flow

Output from Acceptance Testing

% make testacc TESTS=TestAccBedrockAgentFlow PKG=bedrockagent

make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.5 test ./internal/service/bedrockagent/... -v -count 1 -parallel 20 -run='TestAccBedrockAgentFlow'  -timeout 360m -vet=off
2025/04/11 14:38:01 Initializing Terraform AWS Provider...
=== RUN   TestAccBedrockAgentFlow_basic
=== PAUSE TestAccBedrockAgentFlow_basic
=== RUN   TestAccBedrockAgentFlow_disappears
=== PAUSE TestAccBedrockAgentFlow_disappears
=== RUN   TestAccBedrockAgentFlow_withEncryptionKey
=== PAUSE TestAccBedrockAgentFlow_withEncryptionKey
=== RUN   TestAccBedrockAgentFlow_tags
=== PAUSE TestAccBedrockAgentFlow_tags
=== RUN   TestAccBedrockAgentFlow_withDefinition
=== PAUSE TestAccBedrockAgentFlow_withDefinition
=== CONT  TestAccBedrockAgentFlow_basic
=== CONT  TestAccBedrockAgentFlow_tags
=== CONT  TestAccBedrockAgentFlow_disappears
=== CONT  TestAccBedrockAgentFlow_withEncryptionKey
=== CONT  TestAccBedrockAgentFlow_withDefinition
--- PASS: TestAccBedrockAgentFlow_disappears (10.15s)
--- PASS: TestAccBedrockAgentFlow_basic (11.22s)
--- PASS: TestAccBedrockAgentFlow_withEncryptionKey (11.32s)
--- PASS: TestAccBedrockAgentFlow_withDefinition (11.47s)
--- PASS: TestAccBedrockAgentFlow_tags (26.49s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/bedrockagent       30.104s

@delamarch3 delamarch3 requested a review from a team as a code owner April 11, 2025 13:39
Copy link

Community Guidelines

This comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀

Voting for Prioritization

  • Please vote on this Pull Request by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Pull Request and do not help prioritize the request.

Pull Request Authors

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. generators Relates to code generators. service/bedrockagent Issues and PRs that pertain to the bedrockagent service. size/XL Managed by automation to categorize the size of a PR. labels Apr 11, 2025
},
NestedObject: schema.NestedBlockObject{
Blocks: map[string]schema.Block{
"chat": schema.ListNestedBlock{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems impossible to get an inline chat prompt working. It's not possible from the UI and the api returns an invalid template configuration error without saying why. The chat configuration I send to the API is one I got from bedrock prompt management, which uses the exact same structure plus a few more fields - will attach here soon

Copy link
Contributor Author

@delamarch3 delamarch3 Apr 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get prompt output:

% aws bedrock-agent get-prompt --prompt-identifier <prompt-id>

{
    "arn": "<arn>",
    "createdAt": "2025-04-12T12:57:54.406693+00:00",
    "defaultVariant": "variantOne",
    "id": "<prompt-id>",
    "name": "TestPrompt",
    "updatedAt": "2025-04-12T12:58:44.601940+00:00",
    "variants": [
        {
            "inferenceConfiguration": {
                "text": {
                    "maxTokens": 2048,
                    "stopSequences": [
                        "User:"
                    ],
                    "temperature": 0.0,
                    "topP": 0.8999999761581421
                }
            },
            "modelId": "amazon.titan-text-express-v1",
            "name": "variantOne",
            "templateConfiguration": {
                "chat": {
                    "inputVariables": [
                        {
                            "name": "topic"
                        }
                    ],
                    "messages": [
                        {
                            "content": [
                                {
                                    "text": "This is my first text prompt. Please summarize on {{topic}}."
                                }
                            ],
                            "role": "user"
                        },
                        {
                            "content": [
                                {
                                    "text": "Test"
                                }
                            ],
                            "role": "assistant"
                        }
                    ],
                    "system": [
                        {
                            "text": "You are a friendly customer service agent."
                        }
                    ]
                }
            },
            "templateType": "CHAT"
        }
    ],
    "version": "DRAFT"
}

Using the same template configuration in the inline prompt:

% aws bedrock-agent update-flow --flow-identifier <flow-id> --execution-role-arn <role-arn>  --name test --definition \
'{
    "nodes": [
        {
            "configuration": {
                "prompt": {
                    "sourceConfiguration": {
                        "inline": {
                            "modelId": "amazon.titan-text-express-v1",
                            "templateConfiguration": {
                                "chat": {
                                    "inputVariables": [
                                        {
                                            "name": "topic"
                                        }
                                    ],
                                    "messages": [
                                        {
                                            "content": [
                                                {
                                                    "text": "This is my first text prompt. Please summarize on {{topic}}."
                                                }
                                            ],
                                            "role": "user"
                                        },
                                        {
                                            "content": [
                                                {
                                                    "text": "Test"
                                                }
                                            ],
                                            "role": "assistant"
                                        }
                                    ],
                                    "system": [
                                        {
                                            "text": "You are a friendly customer service agent."
                                        }
                                    ]
                                }
                            },
                            "templateType": "CHAT"
                        }
                    }
                }
            },
            "name": "Prompt_1",
            "type": "Prompt"
        }
    ]
}'


An error occurred (ValidationException) when calling the UpdateFlow operation: Invalid prompt template configuration field CHAT provided for the prompt node

@ewbankkit ewbankkit added new-resource Introduces a new resource. and removed needs-triage Waiting for first response or review from a maintainer. labels Apr 13, 2025
Copy link

github-actions bot commented May 16, 2025

✅ Thank you for correcting the previously detected issues! The maintainers appreciate your efforts to make the review process as smooth as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Introduces or discusses updates to documentation. generators Relates to code generators. new-resource Introduces a new resource. service/bedrockagent Issues and PRs that pertain to the bedrockagent service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[New Resource]: Add resources for Bedrock Prompts and Flows
2 participants