AgentcoreResourcePolicy class
Manages an AWS Bedrock Agent Core Resource Policy. Resource-based policies in Amazon Bedrock Agent Core allow you to control which principals (AWS accounts, IAM users, or IAM roles) can invoke and manage your Amazon Bedrock Agent Core Runtime and Gateway resources.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const exampleAgentcoreAgentRuntime = new aws.bedrock.AgentcoreAgentRuntime("example", {});
const example = aws.iam.getPolicyDocumentOutput({
statements: [{
conditions: [{
test: "StringEquals",
variable: "aws:SourceVpc",
values: ["vpc-1a2b3c4d"],
}],
principals: [{
type: "*",
identifiers: ["*"],
}],
sid: "AllowOAuthFromVPC",
effect: "Allow",
actions: ["bedrock-agentcore:InvokeAgentRuntime"],
resources: [exampleAgentcoreAgentRuntime.agentRuntimeArn],
}],
});
const exampleAgentcoreResourcePolicy = new aws.bedrock.AgentcoreResourcePolicy("example", {
policy: example.json,
resourceArn: exampleAgentcoreAgentRuntime.agentRuntimeArn,
});
import pulumi
import pulumi_aws as aws
example_agentcore_agent_runtime = aws.bedrock.AgentcoreAgentRuntime("example")
example = aws.iam.get_policy_document_output(statements=[{
"conditions": [{
"test": "StringEquals",
"variable": "aws:SourceVpc",
"values": ["vpc-1a2b3c4d"],
}],
"principals": [{
"type": "*",
"identifiers": ["*"],
}],
"sid": "AllowOAuthFromVPC",
"effect": "Allow",
"actions": ["bedrock-agentcore:InvokeAgentRuntime"],
"resources": [example_agentcore_agent_runtime.agent_runtime_arn],
}])
example_agentcore_resource_policy = aws.bedrock.AgentcoreResourcePolicy("example",
policy=example.json,
resource_arn=example_agentcore_agent_runtime.agent_runtime_arn)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var exampleAgentcoreAgentRuntime = new Aws.Bedrock.AgentcoreAgentRuntime("example");
var example = Aws.Iam.GetPolicyDocument.Invoke(new()
{
Statements = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
{
Conditions = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
{
Test = "StringEquals",
Variable = "aws:SourceVpc",
Values = new[]
{
"vpc-1a2b3c4d",
},
},
},
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Type = "*",
Identifiers = new[]
{
"*",
},
},
},
Sid = "AllowOAuthFromVPC",
Effect = "Allow",
Actions = new[]
{
"bedrock-agentcore:InvokeAgentRuntime",
},
Resources = new[]
{
exampleAgentcoreAgentRuntime.AgentRuntimeArn,
},
},
},
});
var exampleAgentcoreResourcePolicy = new Aws.Bedrock.AgentcoreResourcePolicy("example", new()
{
Policy = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
ResourceArn = exampleAgentcoreAgentRuntime.AgentRuntimeArn,
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/bedrock"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleAgentcoreAgentRuntime, err := bedrock.NewAgentcoreAgentRuntime(ctx, "example", nil)
if err != nil {
return err
}
example := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
Statements: iam.GetPolicyDocumentStatementArray{
&iam.GetPolicyDocumentStatementArgs{
Conditions: iam.GetPolicyDocumentStatementConditionArray{
&iam.GetPolicyDocumentStatementConditionArgs{
Test: pulumi.String("StringEquals"),
Variable: pulumi.String("aws:SourceVpc"),
Values: pulumi.StringArray{
pulumi.String("vpc-1a2b3c4d"),
},
},
},
Principals: iam.GetPolicyDocumentStatementPrincipalArray{
&iam.GetPolicyDocumentStatementPrincipalArgs{
Type: pulumi.String("*"),
Identifiers: pulumi.StringArray{
pulumi.String("*"),
},
},
},
Sid: pulumi.String("AllowOAuthFromVPC"),
Effect: pulumi.String("Allow"),
Actions: pulumi.StringArray{
pulumi.String("bedrock-agentcore:InvokeAgentRuntime"),
},
Resources: pulumi.StringArray{
exampleAgentcoreAgentRuntime.AgentRuntimeArn,
},
},
},
}, nil)
_, err = bedrock.NewAgentcoreResourcePolicy(ctx, "example", &bedrock.AgentcoreResourcePolicyArgs{
Policy: example.Json(),
ResourceArn: exampleAgentcoreAgentRuntime.AgentRuntimeArn,
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_iam_getpolicydocument" "example" {
statements {
conditions {
test = "StringEquals"
variable = "aws:SourceVpc"
values = ["vpc-1a2b3c4d"]
}
principals {
type = "*"
identifiers = ["*"]
}
sid = "AllowOAuthFromVPC"
effect = "Allow"
actions = ["bedrock-agentcore:InvokeAgentRuntime"]
resources = [aws_bedrock_agentcoreagentruntime.example.agent_runtime_arn]
}
}
resource "aws_bedrock_agentcoreagentruntime" "example" {
}
resource "aws_bedrock_agentcoreresourcepolicy" "example" {
policy = data.aws_iam_getpolicydocument.example.json
resource_arn = aws_bedrock_agentcoreagentruntime.example.agent_runtime_arn
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.bedrock.AgentcoreAgentRuntime;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementConditionArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.bedrock.AgentcoreResourcePolicy;
import com.pulumi.aws.bedrock.AgentcoreResourcePolicyArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var exampleAgentcoreAgentRuntime = new AgentcoreAgentRuntime("exampleAgentcoreAgentRuntime");
final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.conditions(GetPolicyDocumentStatementConditionArgs.builder()
.test("StringEquals")
.variable("aws:SourceVpc")
.values("vpc-1a2b3c4d")
.build())
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("*")
.identifiers("*")
.build())
.sid("AllowOAuthFromVPC")
.effect("Allow")
.actions("bedrock-agentcore:InvokeAgentRuntime")
.resources(exampleAgentcoreAgentRuntime.agentRuntimeArn())
.build())
.build());
var exampleAgentcoreResourcePolicy = new AgentcoreResourcePolicy("exampleAgentcoreResourcePolicy", AgentcoreResourcePolicyArgs.builder()
.policy(example.applyValue(_example -> _example.json()))
.resourceArn(exampleAgentcoreAgentRuntime.agentRuntimeArn())
.build());
}
}
resources:
exampleAgentcoreAgentRuntime:
type: aws:bedrock:AgentcoreAgentRuntime
name: example
exampleAgentcoreResourcePolicy:
type: aws:bedrock:AgentcoreResourcePolicy
name: example
properties:
policy: ${example.json}
resourceArn: ${exampleAgentcoreAgentRuntime.agentRuntimeArn}
variables:
example:
fn::invoke:
function: aws:iam:getPolicyDocument
arguments:
statements:
- conditions:
- test: StringEquals
variable: aws:SourceVpc
values:
- vpc-1a2b3c4d
principals:
- type: '*'
identifiers:
- '*'
sid: AllowOAuthFromVPC
effect: Allow
actions:
- bedrock-agentcore:InvokeAgentRuntime
resources:
- ${exampleAgentcoreAgentRuntime.agentRuntimeArn}
Import
Identity Schema
Required
resourceArn- ARN of the resource to which the Resource Policy is attached.
Using pulumi import, import Bedrock Agent Core Resource Policy using the resourceArn. For example:
$ pulumi import aws:bedrock/agentcoreResourcePolicy:AgentcoreResourcePolicy example arn:aws:bedrock-agentcore:us-west-2:012345678901:runtime/abcd1234
Constructors
- AgentcoreResourcePolicy(String name, {AgentcoreResourcePolicyArgs? args, CustomResourceOptions? options})
-
Creates a new AgentcoreResourcePolicy.
nameThe Pulumi resource name.argsArguments used to configure this AgentcoreResourcePolicy. The set of arguments for AgentcoreResourcePolicy.optionsResource options controlling this resource's behavior. - AgentcoreResourcePolicy.reference(String urn)
- Creates a typed reference to an existing AgentcoreResourcePolicy resource.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
policy
↔ Output<
String> -
Resource policy definition
latefinal
-
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceArn
↔ Output<
String> -
ARN of the resource for which to create or update the resource policy.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {AgentcoreResourcePolicyState? state, CustomResourceOptions? options}) → AgentcoreResourcePolicy -
Gets an existing AgentcoreResourcePolicy resource's state with the given
nameandid.