Skip to content

Commit

Permalink
Merge pull request #37586 from acwwat/f-aws_bedrockagent_agent-add_sk…
Browse files Browse the repository at this point in the history
…lp_resoource_in_use_check_arg

feat: Add skip_resource_in_use_check arg to aws_bedrockagent_agent
  • Loading branch information
ewbankkit authored Jul 18, 2024
2 parents 752a0d8 + 87b1d55 commit 8675eee
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .changelog/37586.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_bedrockagent_agent : Add `skip_resource_in_use_check` argument
```
12 changes: 11 additions & 1 deletion internal/service/bedrockagent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ func (r *agentResource) Schema(ctx context.Context, request resource.SchemaReque
boolplanmodifier.UseStateForUnknown(),
},
},
"skip_resource_in_use_check": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
PlanModifiers: []planmodifier.Bool{
boolplanmodifier.UseStateForUnknown(),
},
},
names.AttrTags: tftags.TagsAttribute(),
names.AttrTagsAll: tftags.TagsAttributeComputedOnly(),
},
Expand Down Expand Up @@ -344,7 +352,8 @@ func (r *agentResource) Delete(ctx context.Context, request resource.DeleteReque

agentID := data.ID.ValueString()
_, err := conn.DeleteAgent(ctx, &bedrockagent.DeleteAgentInput{
AgentId: fwflex.StringFromFramework(ctx, data.AgentID),
AgentId: fwflex.StringFromFramework(ctx, data.AgentID),
SkipResourceInUseCheck: fwflex.BoolValueFromFramework(ctx, data.SkipResourceInUseCheck),
})

if errs.IsA[*awstypes.ResourceNotFoundException](err) {
Expand Down Expand Up @@ -544,6 +553,7 @@ type agentResourceModel struct {
Instruction types.String `tfsdk:"instruction"`
PrepareAgent types.Bool `tfsdk:"prepare_agent"`
PromptOverrideConfiguration fwtypes.ListNestedObjectValueOf[promptOverrideConfigurationModel] `tfsdk:"prompt_override_configuration"`
SkipResourceInUseCheck types.Bool `tfsdk:"skip_resource_in_use_check"`
Tags types.Map `tfsdk:"tags"`
TagsAll types.Map `tfsdk:"tags_all"`
Timeouts timeouts.Value `tfsdk:"timeouts"`
Expand Down
30 changes: 18 additions & 12 deletions internal/service/bedrockagent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ func TestAccBedrockAgentAgent_basic(t *testing.T) {
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"skip_resource_in_use_check"},
},
},
})
Expand All @@ -69,12 +70,14 @@ func TestAccBedrockAgentAgent_full(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "agent_name", rName),
resource.TestCheckResourceAttr(resourceName, "prompt_override_configuration.#", acctest.Ct1),
resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "basic claude"),
resource.TestCheckResourceAttr(resourceName, "skip_resource_in_use_check", acctest.CtTrue),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"skip_resource_in_use_check"},
},
},
})
Expand Down Expand Up @@ -120,9 +123,10 @@ func TestAccBedrockAgentAgent_update(t *testing.T) {
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"skip_resource_in_use_check"},
},
},
})
Expand All @@ -149,9 +153,10 @@ func TestAccBedrockAgentAgent_tags(t *testing.T) {
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"skip_resource_in_use_check"},
},
{
Config: testAccAgentConfig_tags2(rName, "anthropic.claude-v2", acctest.CtKey1, acctest.CtValue1Updated, acctest.CtKey2, acctest.CtValue2),
Expand Down Expand Up @@ -335,6 +340,7 @@ resource "aws_bedrockagent_agent" "test" {
idle_session_ttl_in_seconds = 500
instruction = file("${path.module}/test-fixtures/instruction.txt")
foundation_model = %[2]q
skip_resource_in_use_check = true
prompt_override_configuration {
override_lambda = null
Expand Down
13 changes: 7 additions & 6 deletions website/docs/r/bedrockagent_agent.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,29 @@ The following arguments are optional:
* `idle_session_ttl_in_seconds` - (Optional) Number of seconds for which Amazon Bedrock keeps information about a user's conversation with the agent. A user interaction remains active for the amount of time specified. If no conversation occurs during this time, the session expires and Amazon Bedrock deletes any data provided before the timeout.
* `instruction` - (Optional) Instructions that tell the agent what it should do and how it should interact with users.
* `prepare_agent` (Optional) Whether to prepare the agent after creation or modification. Defaults to `true`.
* `prompt_override_configuration` (Optional) Configurations to override prompt templates in different parts of an agent sequence. For more information, see [Advanced prompts](https://docs.aws.amazon.com/bedrock/latest/userguide/advanced-prompts.html). See [`prompt_override_configuration` block](#prompt_override_configuration-block) for details.
* `prompt_override_configuration` (Optional) Configurations to override prompt templates in different parts of an agent sequence. For more information, see [Advanced prompts](https://docs.aws.amazon.com/bedrock/latest/userguide/advanced-prompts.html). See [`prompt_override_configuration` Block](#prompt_override_configuration-block) for details.
* `skip_resource_in_use_check` - (Optional) Whether the in-use check is skipped when deleting the agent.
* `tags` - (Optional) Map of tags assigned to the resource. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.

### `prompt_override_configuration` block
### `prompt_override_configuration` Block

The `prompt_override_configuration` configuration block supports the following arguments:

* `prompt_configurations` - (Required) Configurations to override a prompt template in one part of an agent sequence. See [`prompt_configurations` block](#prompt_configurations-block) for details.
* `prompt_configurations` - (Required) Configurations to override a prompt template in one part of an agent sequence. See [`prompt_configurations` Block](#prompt_configurations-block) for details.
* `override_lambda` - (Optional) ARN of the Lambda function to use when parsing the raw foundation model output in parts of the agent sequence. If you specify this field, at least one of the `prompt_configurations` block must contain a `parser_mode` value that is set to `OVERRIDDEN`.

### `prompt_configurations` block
### `prompt_configurations` Block

The `prompt_configurations` configuration block supports the following arguments:

* `base_prompt_template` - (Required) prompt template with which to replace the default prompt template. You can use placeholder variables in the base prompt template to customize the prompt. For more information, see [Prompt template placeholder variables](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-placeholders.html).
* `inference_configuration` - (Required) Inference parameters to use when the agent invokes a foundation model in the part of the agent sequence defined by the `prompt_type`. For more information, see [Inference parameters for foundation models](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html). See [`inference_configuration` block](#inference_configuration-block) for details.
* `inference_configuration` - (Required) Inference parameters to use when the agent invokes a foundation model in the part of the agent sequence defined by the `prompt_type`. For more information, see [Inference parameters for foundation models](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html). See [`inference_configuration` Block](#inference_configuration-block) for details.
* `parser_mode` - (Required) Whether to override the default parser Lambda function when parsing the raw foundation model output in the part of the agent sequence defined by the `prompt_type`. If you set the argument as `OVERRIDDEN`, the `override_lambda` argument in the [`prompt_override_configuration`](#prompt_override_configuration-block) block must be specified with the ARN of a Lambda function. Valid values: `DEFAULT`, `OVERRIDDEN`.
* `prompt_creation_mode` - (Required) Whether to override the default prompt template for this `prompt_type`. Set this argument to `OVERRIDDEN` to use the prompt that you provide in the `base_prompt_template`. If you leave it as `DEFAULT`, the agent uses a default prompt template. Valid values: `DEFAULT`, `OVERRIDDEN`.
* `prompt_state` - (Required) Whether to allow the agent to carry out the step specified in the `prompt_type`. If you set this argument to `DISABLED`, the agent skips that step. Valid Values: `ENABLED`, `DISABLED`.
* `prompt_type` - (Required) Step in the agent sequence that this prompt configuration applies to. Valid values: `PRE_PROCESSING`, `ORCHESTRATION`, `POST_PROCESSING`, `KNOWLEDGE_BASE_RESPONSE_GENERATION`.

### `inference_configuration` block
### `inference_configuration` Block

The `inference_configuration` configuration block supports the following arguments:

Expand Down

0 comments on commit 8675eee

Please sign in to comment.