BrowserCustom L2 construct
Browser resource for AWS Bedrock Agent Core.
Provides a browser environment for web automation and interaction.
Example
const browser = new agentcore.BrowserCustom(this, 'BrowserVpcWithRecording', {
browserCustomName: 'browser_recording',
networkConfiguration: agentcore.BrowserNetworkConfiguration.usingVpc(this, {
vpc: new ec2.Vpc(this, 'VPC', { restrictDefaultSecurityGroup: false }),
}),
});
browser = agentcore.BrowserCustom(self, "BrowserVpcWithRecording",
browser_custom_name="browser_recording",
network_configuration=agentcore.BrowserNetworkConfiguration.using_vpc(self,
vpc=ec2.Vpc(self, "VPC", restrict_default_security_group=False)
)
)
BrowserCustom browser = BrowserCustom.Builder.create(this, "BrowserVpcWithRecording")
.browserCustomName("browser_recording")
.networkConfiguration(BrowserNetworkConfiguration.usingVpc(this, VpcConfigProps.builder()
.vpc(Vpc.Builder.create(this, "VPC").restrictDefaultSecurityGroup(false).build())
.build()))
.build();
// Install: dotnet add package Amazon.CDK.Lib
var browser = new BrowserCustom(this, "BrowserVpcWithRecording", new BrowserCustomProps {
BrowserCustomName = "browser_recording",
NetworkConfiguration = BrowserNetworkConfiguration.UsingVpc(this, new VpcConfigProps {
Vpc = new Vpc(this, "VPC", new VpcProps { RestrictDefaultSecurityGroup = false })
})
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
browser := agentcore.NewBrowserCustom(this, jsii.String("BrowserVpcWithRecording"), &BrowserCustomProps{
BrowserCustomName: jsii.String("browser_recording"),
NetworkConfiguration: agentcore.BrowserNetworkConfiguration_UsingVpc(this, &VpcConfigProps{
Vpc: ec2.NewVpc(this, jsii.String("VPC"), &VpcProps{
RestrictDefaultSecurityGroup: jsii.Boolean(false),
}),
}),
})
Initializer
new BrowserCustom(scope: Construct, id: string, props?: BrowserCustomProps)
BrowserCustom(scope: Construct, id: str, props: typing.Optional[BrowserCustomProps] = None)
new BrowserCustom(Construct scope, String id, BrowserCustomProps props)
new BrowserCustom(Construct scope, string id, BrowserCustomProps? props = null)
NewBrowserCustom(Scope Construct, Id *string, Props BrowserCustomProps)
Construct Props
browserCustomNamestringbrowser_custom_namestrbrowserCustomNameStringBrowserCustomNamestringBrowserCustomName*string= auto generate#browserSigningBrowserSigningbrowser_signingBrowserSigningbrowserSigningBrowserSigningBrowserSigningBrowserSigningBrowserSigningBrowserSigning= BrowserSigning.DISABLED#When enabled, the browser will cryptographically sign HTTP requests to identify itself as an AI agent to bot control vendors.
descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*string= No description#executionRoleIRoleexecution_roleIRoleexecutionRoleIRoleExecutionRoleIRoleExecutionRoleIRole= A new role will be created#networkConfigurationBrowserNetworkConfigurationnetwork_configurationBrowserNetworkConfigurationnetworkConfigurationBrowserNetworkConfigurationNetworkConfigurationBrowserNetworkConfigurationNetworkConfigurationBrowserNetworkConfiguration= PUBLIC network mode#recordingConfigRecordingConfigrecording_configRecordingConfigrecordingConfigRecordingConfigRecordingConfigRecordingConfigRecordingConfigRecordingConfig= No recording configuration#tags{ [key: string]: string }tagstyping.Mapping[str, str]tagsMap<String, String>TagsIDictionary<string, string>Tags*map[string]*string= {} - no tags#Properties
browserCustomNamestringbrowser_custom_namestrbrowserCustomNameStringBrowserCustomNamestringBrowserCustomName*stringrequired#browserCustomRefBrowserCustomReferencebrowser_custom_refBrowserCustomReferencebrowserCustomRefBrowserCustomReferenceBrowserCustomRefBrowserCustomReferenceBrowserCustomRefBrowserCustomReferencerequired#browserSigningBrowserSigningbrowser_signingBrowserSigningbrowserSigningBrowserSigningBrowserSigningBrowserSigningBrowserSigningBrowserSigning#connectionsConnectionsconnectionsConnectionsconnectionsConnectionsConnectionsConnectionsConnectionsConnectionsrequired#envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#notes
For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
executionRoleIRoleexecution_roleIRoleexecutionRoleIRoleExecutionRoleIRoleExecutionRoleIRolerequired#grantPrincipalIPrincipalgrant_principalIPrincipalgrantPrincipalIPrincipalGrantPrincipalIPrincipalGrantPrincipalIPrincipalrequired#networkConfigurationBrowserNetworkConfigurationnetwork_configurationBrowserNetworkConfigurationnetworkConfigurationBrowserNetworkConfigurationNetworkConfigurationBrowserNetworkConfigurationNetworkConfigurationBrowserNetworkConfigurationrequired#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#recordingConfigRecordingConfigrecording_configRecordingConfigrecordingConfigRecordingConfigRecordingConfigRecordingConfigRecordingConfigRecordingConfig#tags{ [key: string]: string }tagstyping.Mapping[str, str]tagsMap<String, String>TagsIDictionary<string, string>Tags*map[string]*string= No tags applied#Methods
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).
fromBrowserCustomAttributes(scope: Construct, id: string, attrs: BrowserCustomAttributes): IBrowserCustom@staticmethod def from_browser_custom_attributes(scope: Construct, id: str, attrs: BrowserCustomAttributes) -> IBrowserCustompublic static IBrowserCustom fromBrowserCustomAttributes(Construct scope, String id, BrowserCustomAttributes attrs)public static IBrowserCustom FromBrowserCustomAttributes(Construct scope, string id, BrowserCustomAttributes attrs)func FromBrowserCustomAttributes(Scope Construct, Id *string, Attrs BrowserCustomAttributes) IBrowserCustomstatic#3 parameters · returns
Parameters
scopescopescopescopeScope— - The construct scope.ididididId— - Identifier of the construct.attrsattrsattrsattrsAttrs— - Attributes of the existing browser custom.
Returns: An IBrowserCustom reference to the existing browser
grant(grantee: IGrantable, ...actions: string[]): Grantdef grant(self, grantee: IGrantable, actions: str) -> Grantpublic Grant grant(IGrantable grantee, String actions)public Grant Grant(IGrantable grantee, string actions)func Grant(Grantee IGrantable, Actions *string) Grant#[disable-awslint:no-grants]
2 parameters · returns
Parameters
granteegranteegranteegranteeGrantee— - The IAM principal to grant permissions to.actionsactionsactionsactionsActions— - The actions to grant.
Returns: An IAM Grant object representing the granted permissions
grantRead(grantee: IGrantable): Grantdef grant_read(self, grantee: IGrantable) -> Grantpublic Grant grantRead(IGrantable grantee)public Grant GrantRead(IGrantable grantee)func GrantRead(Grantee IGrantable) Grant#This includes both read permissions on the specific browser and list permissions on all browsers.
[disable-awslint:no-grants]
1 parameter · returns
Parameters
granteegranteegranteegranteeGrantee— - The IAM principal to grant read permissions to.
Returns: An IAM Grant object representing the granted permissions
grantUse(grantee: IGrantable): Grantdef grant_use(self, grantee: IGrantable) -> Grantpublic Grant grantUse(IGrantable grantee)public Grant GrantUse(IGrantable grantee)func GrantUse(Grantee IGrantable) Grant#notes · 1 parameter · returns
This includes ConnectBrowserAutomationStream, which is required to connect to the automation stream of a session over the Chrome DevTools Protocol. Without it, StartBrowserSession succeeds but the subsequent connection to the returned stream endpoint is rejected.
[disable-awslint:no-grants]
Parameters
granteegranteegranteegranteeGrantee— - The IAM principal to grant use permissions to.
Returns: An IAM Grant object representing the granted permissions
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#metric(metricName: string, props?: MetricOptions): Metricdef metric(self, metric_name: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metric(String metricName, MetricOptions props)public Metric Metric(string metricName, MetricOptions? props = null)func Metric(MetricName *string, Props MetricOptions) Metric#By default, the metric will be calculated as a sum over a period of 5 minutes. You can customize this by using the statistic and period properties.
metricErrorsForApiOperation(operation: string, props?: MetricOptions): Metricdef metric_errors_for_api_operation(self, operation: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricErrorsForApiOperation(String operation, MetricOptions props)public Metric MetricErrorsForApiOperation(string operation, MetricOptions? props = null)func MetricErrorsForApiOperation(Operation *string, Props MetricOptions) Metric#1 parameter · returns
Parameters
propspropspropspropsProps— - Configuration options for the metric.
Returns: A CloudWatch Metric configured for browser errors
metricForApiOperation(metricName: string, operation: string, props?: MetricOptions): Metricdef metric_for_api_operation(self, metric_name: str, operation: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricForApiOperation(String metricName, String operation, MetricOptions props)public Metric MetricForApiOperation(string metricName, string operation, MetricOptions? props = null)func MetricForApiOperation(MetricName *string, Operation *string, Props MetricOptions) Metric#1 parameter · returns
Parameters
propspropspropspropsProps— - Configuration options for the metric.
Returns: A CloudWatch Metric configured for browser api operations
metricInvocationsForApiOperation(operation: string, props?: MetricOptions): Metricdef metric_invocations_for_api_operation(self, operation: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricInvocationsForApiOperation(String operation, MetricOptions props)public Metric MetricInvocationsForApiOperation(string operation, MetricOptions? props = null)func MetricInvocationsForApiOperation(Operation *string, Props MetricOptions) Metric#1 parameter · returns
Parameters
propspropspropspropsProps— - Configuration options for the metric.
Returns: A CloudWatch Metric configured for browser latencies
metricLatencyForApiOperation(operation: string, props?: MetricOptions): Metricdef metric_latency_for_api_operation(self, operation: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricLatencyForApiOperation(String operation, MetricOptions props)public Metric MetricLatencyForApiOperation(string operation, MetricOptions? props = null)func MetricLatencyForApiOperation(Operation *string, Props MetricOptions) Metric#1 parameter · returns
Parameters
propspropspropspropsProps— - Configuration options for the metric.
Returns: A CloudWatch Metric configured for browser latencies
metricSessionDuration(props?: MetricOptions): Metricdef metric_session_duration(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricSessionDuration(MetricOptions props)public Metric MetricSessionDuration(MetricOptions? props = null)func MetricSessionDuration(Props MetricOptions) Metric#1 parameter · returns
Parameters
propspropspropspropsProps— - Configuration options for the metric.
Returns: A CloudWatch Metric configured for browser session duration
metricSystemErrorsForApiOperation(operation: string, props?: MetricOptions): Metricdef metric_system_errors_for_api_operation(self, operation: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricSystemErrorsForApiOperation(String operation, MetricOptions props)public Metric MetricSystemErrorsForApiOperation(string operation, MetricOptions? props = null)func MetricSystemErrorsForApiOperation(Operation *string, Props MetricOptions) Metric#1 parameter · returns
Parameters
propspropspropspropsProps— - Configuration options for the metric.
Returns: A CloudWatch Metric configured for browser system errors
metricTakeOverCount(props?: MetricOptions): Metricdef metric_take_over_count(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricTakeOverCount(MetricOptions props)public Metric MetricTakeOverCount(MetricOptions? props = null)func MetricTakeOverCount(Props MetricOptions) Metric#1 parameter · returns
Parameters
propspropspropspropsProps— - Configuration options for the metric.
Returns: A CloudWatch Metric configured for browser user takeovers
metricTakeOverDuration(props?: MetricOptions): Metricdef metric_take_over_duration(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricTakeOverDuration(MetricOptions props)public Metric MetricTakeOverDuration(MetricOptions? props = null)func MetricTakeOverDuration(Props MetricOptions) Metric#1 parameter · returns
Parameters
propspropspropspropsProps— - Configuration options for the metric.
Returns: A CloudWatch Metric configured for browser user takeovers duration
metricTakeOverReleaseCount(props?: MetricOptions): Metricdef metric_take_over_release_count(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricTakeOverReleaseCount(MetricOptions props)public Metric MetricTakeOverReleaseCount(MetricOptions? props = null)func MetricTakeOverReleaseCount(Props MetricOptions) Metric#1 parameter · returns
Parameters
propspropspropspropsProps— - Configuration options for the metric.
Returns: A CloudWatch Metric configured for browser user takeovers released
metricThrottlesForApiOperation(operation: string, props?: MetricOptions): Metricdef metric_throttles_for_api_operation(self, operation: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricThrottlesForApiOperation(String operation, MetricOptions props)public Metric MetricThrottlesForApiOperation(string operation, MetricOptions? props = null)func MetricThrottlesForApiOperation(Operation *string, Props MetricOptions) Metric#1 parameter · returns
Parameters
propspropspropspropsProps— - Configuration options for the metric.
Returns: A CloudWatch Metric configured for browser throttles
metricUserErrorsForApiOperation(operation: string, props?: MetricOptions): Metricdef metric_user_errors_for_api_operation(self, operation: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricUserErrorsForApiOperation(String operation, MetricOptions props)public Metric MetricUserErrorsForApiOperation(string operation, MetricOptions? props = null)func MetricUserErrorsForApiOperation(Operation *string, Props MetricOptions) Metric#1 parameter · returns
Parameters
propspropspropspropsProps— - Configuration options for the metric.
Returns: A CloudWatch Metric configured for browser user errors
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.