Experimental
@aws-cdk/aws-bedrock-agentcore-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
AddPolicyOptions Struct
Options for adding a policy via PolicyEngine.addPolicy().
Example
declare const policyEngine: agentcore.PolicyEngine;
declare const gateway: agentcore.Gateway;
// Allow specific tool actions on specific gateway
// Action names follow pattern: "ToolName__operation"
policyEngine.addPolicy("SpecificToolPolicy", {
statement: agentcore.PolicyStatement.permit()
.forPrincipal('AgentCore::OAuthUser::your-client-id')
.onActions([
'AgentCore::Action::WeatherTool__get_forecast',
'AgentCore::Action::WeatherTool__get_current',
])
.onResource('AgentCore::Gateway', gateway.gatewayArn),
description: "Allow specific weather tool operations",
validationMode: agentcore.PolicyValidationMode.FAIL_ON_ANY_FINDINGS,
});
// Generated Cedar:
// permit(
// principal is AgentCore::OAuthUser,
// action in [
// AgentCore::Action::"WeatherTool__get_forecast",
// AgentCore::Action::"WeatherTool__get_current"
// ],
// resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-east-1:123:gateway/gw-123"
// );
# policy_engine: agentcore.PolicyEngine
# gateway: agentcore.Gateway
# Allow specific tool actions on specific gateway
# Action names follow pattern: "ToolName__operation"
policy_engine.add_policy("SpecificToolPolicy",
statement=agentcore.PolicyStatement.permit().for_principal("AgentCore::OAuthUser::your-client-id").on_actions(["AgentCore::Action::WeatherTool__get_forecast", "AgentCore::Action::WeatherTool__get_current"
]).on_resource("AgentCore::Gateway", gateway.gateway_arn),
description="Allow specific weather tool operations",
validation_mode=agentcore.PolicyValidationMode.FAIL_ON_ANY_FINDINGS
)
PolicyEngine policyEngine;
Gateway gateway;
// Allow specific tool actions on specific gateway
// Action names follow pattern: "ToolName__operation"
policyEngine.addPolicy("SpecificToolPolicy", AddPolicyOptions.builder()
.statement(PolicyStatement.permit().forPrincipal("AgentCore::OAuthUser::your-client-id").onActions(List.of("AgentCore::Action::WeatherTool__get_forecast", "AgentCore::Action::WeatherTool__get_current")).onResource("AgentCore::Gateway", gateway.getGatewayArn()))
.description("Allow specific weather tool operations")
.validationMode(PolicyValidationMode.FAIL_ON_ANY_FINDINGS)
.build());
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Agentcore.Alpha
PolicyEngine policyEngine;
Gateway gateway;
// Allow specific tool actions on specific gateway
// Action names follow pattern: "ToolName__operation"
policyEngine.AddPolicy("SpecificToolPolicy", new AddPolicyOptions {
Statement = PolicyStatement.Permit().ForPrincipal("AgentCore::OAuthUser::your-client-id").OnActions(new [] { "AgentCore::Action::WeatherTool__get_forecast", "AgentCore::Action::WeatherTool__get_current" }).OnResource("AgentCore::Gateway", gateway.GatewayArn),
Description = "Allow specific weather tool operations",
ValidationMode = PolicyValidationMode.FAIL_ON_ANY_FINDINGS
});
// Install: go get github.com/aws/aws-cdk-go/awsbedrockagentcorealpha/v2
var policyEngine PolicyEngine
var gateway Gateway
// Allow specific tool actions on specific gateway
// Action names follow pattern: "ToolName__operation"
policyEngine.AddPolicy(jsii.String("SpecificToolPolicy"), &AddPolicyOptions{
Statement: agentcore.PolicyStatement_Permit().ForPrincipal(jsii.String("AgentCore::OAuthUser::your-client-id")).OnActions([]*string{
jsii.String("AgentCore::Action::WeatherTool__get_forecast"),
jsii.String("AgentCore::Action::WeatherTool__get_current"),
}).OnResource(jsii.String("AgentCore::Gateway"), gateway.GatewayArn),
Description: jsii.String("Allow specific weather tool operations"),
ValidationMode: agentcore.PolicyValidationMode_FAIL_ON_ANY_FINDINGS(),
})
Properties
definitionoptionalstringdefinitionoptionalstrdefinitionoptionalStringDefinitionoptionalstringDefinitionoptional*string#Default: Must provide either definition or statement
You must specify either definition or statement, but not both.
descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string#Default: No description
policyNameoptionalstringpolicy_nameoptionalstrpolicyNameoptionalStringPolicyNameoptionalstringPolicyNameoptional*string#Default: Auto-generated unique name
Valid characters: a-z, A-Z, 0-9, _ (underscore) Must start with a letter, 1-48 characters
statementoptionalPolicyStatementstatementoptionalPolicyStatementstatementoptionalPolicyStatementStatementoptionalPolicyStatementStatementoptionalPolicyStatement#Default: Must provide either definition or statement
Use this for a type-safe, form-like API to build Cedar policies without writing raw Cedar syntax. The builder validates at synthesis time.
You must specify either definition or statement, but not both.
validationModeoptionalPolicyValidationModevalidation_modeoptionalPolicyValidationModevalidationModeoptionalPolicyValidationModeValidationModeoptionalPolicyValidationModeValidationModeoptionalPolicyValidationMode#Default: PolicyValidationMode.FAIL_ON_ANY_FINDINGS