Skip to content
v2.275.0

Experimental

@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

ApplicationInferenceProfile L1 construct ​

Class to create an Application Inference Profile with CDK.

These are inference profiles created by users (user defined). This helps to track costs and model usage.

Application inference profiles are user-defined profiles that help you track costs and model usage. They can be created for a single region or for multiple regions using a cross-region inference profile.

Example ​

ts
// Create a cross-region inference profile
const crossRegionProfile = bedrock.CrossRegionInferenceProfile.fromConfig({
  geoRegion: bedrock.CrossRegionInferenceProfileRegion.US,
  model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V2_0,
});

// Create an application inference profile across regions
const appProfile = new bedrock.ApplicationInferenceProfile(this, 'MyMultiRegionProfile', {
  applicationInferenceProfileName: 'claude-35-sonnet-v2-multi-region',
  modelSource: crossRegionProfile,
  description: 'Multi-region application profile for cost tracking',
});
python
# Create a cross-region inference profile
cross_region_profile = bedrock.CrossRegionInferenceProfile.from_config(
    geo_region=bedrock.CrossRegionInferenceProfileRegion.US,
    model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V2_0
)

# Create an application inference profile across regions
app_profile = bedrock.ApplicationInferenceProfile(self, "MyMultiRegionProfile",
    application_inference_profile_name="claude-35-sonnet-v2-multi-region",
    model_source=cross_region_profile,
    description="Multi-region application profile for cost tracking"
)
java
// Create a cross-region inference profile
CrossRegionInferenceProfile crossRegionProfile = CrossRegionInferenceProfile.fromConfig(CrossRegionInferenceProfileProps.builder()
        .geoRegion(CrossRegionInferenceProfileRegion.US)
        .model(BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V2_0)
        .build());

// Create an application inference profile across regions
ApplicationInferenceProfile appProfile = ApplicationInferenceProfile.Builder.create(this, "MyMultiRegionProfile")
        .applicationInferenceProfileName("claude-35-sonnet-v2-multi-region")
        .modelSource(crossRegionProfile)
        .description("Multi-region application profile for cost tracking")
        .build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
// Create a cross-region inference profile
var crossRegionProfile = CrossRegionInferenceProfile.FromConfig(new CrossRegionInferenceProfileProps {
    GeoRegion = CrossRegionInferenceProfileRegion.US,
    Model = BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V2_0
});

// Create an application inference profile across regions
var appProfile = new ApplicationInferenceProfile(this, "MyMultiRegionProfile", new ApplicationInferenceProfileProps {
    ApplicationInferenceProfileName = "claude-35-sonnet-v2-multi-region",
    ModelSource = crossRegionProfile,
    Description = "Multi-region application profile for cost tracking"
});
go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
// Create a cross-region inference profile
crossRegionProfile := bedrock.CrossRegionInferenceProfile_FromConfig(&CrossRegionInferenceProfileProps{
	GeoRegion: bedrock.CrossRegionInferenceProfileRegion_US,
	Model: bedrock.BedrockFoundationModel_ANTHROPIC_CLAUDE_3_5_SONNET_V2_0(),
})

// Create an application inference profile across regions
appProfile := bedrock.NewApplicationInferenceProfile(this, jsii.String("MyMultiRegionProfile"), &ApplicationInferenceProfileProps{
	ApplicationInferenceProfileName: jsii.String("claude-35-sonnet-v2-multi-region"),
	ModelSource: crossRegionProfile,
	Description: jsii.String("Multi-region application profile for cost tracking"),
})

Initializer ​

ts
new ApplicationInferenceProfile(scope: Construct, id: string, props: ApplicationInferenceProfileProps)
python
ApplicationInferenceProfile(scope: Construct, id: str, props: ApplicationInferenceProfileProps)
java
new ApplicationInferenceProfile(Construct scope, String id, ApplicationInferenceProfileProps props)
csharp
new ApplicationInferenceProfile(Construct scope, string id, ApplicationInferenceProfileProps props)
go
NewApplicationInferenceProfile(Scope Construct, Id *string, Props ApplicationInferenceProfileProps)

Construct Props ​

applicationInferenceProfileNamestringapplication_inference_profile_namestrapplicationInferenceProfileNameStringApplicationInferenceProfileNamestringApplicationInferenceProfileName*stringrequired#
The name of the application inference profile.

This name will be used to identify the inference profile in the AWS console and APIs.

  • Required: Yes
  • Maximum length: 64 characters
  • Pattern: ^([0-9a-zA-Z:.][ _-]?)+$
descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string#
Description of the inference profile. Provides additional context about the purpose and usage of this inference profile.

Default: No description is provided

  • Maximum length: 200 characters when provided
  • Pattern: ^([0-9a-zA-Z:.][ _-]?)+$
modelSourceIBedrockInvokablemodel_sourceIBedrockInvokablemodelSourceIBedrockInvokableModelSourceIBedrockInvokableModelSourceIBedrockInvokablerequired#
The model source for this inference profile.
notes

To create an application inference profile for one Region, specify a foundation model. Usage and costs for requests made to that Region with that model will be tracked.

To create an application inference profile for multiple Regions, specify a cross region (system-defined) inference profile. The inference profile will route requests to the Regions defined in the cross region (system-defined) inference profile that you choose. Usage and costs for requests made to the Regions in the inference profile will be tracked.

tagsoptional{ [key: string]: string }tagsoptionaltyping.Mapping[str, str]tagsoptionalMap<String, String>TagsoptionalIDictionary<string, string>Tagsoptional*map[string]*string#
A list of tags associated with the inference profile.

Default: No tags are applied

Tags help you organize and categorize your AWS resources.

Properties ​

createdAtstringcreated_atstrcreatedAtStringCreatedAtstringCreatedAt*string#
Time Stamp for Application Inference Profile creation.
The environment this resource belongs to.
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.

inferenceProfileArnstringinference_profile_arnstrinferenceProfileArnStringInferenceProfileArnstringInferenceProfileArn*string#
The ARN of the application inference profile.
inferenceProfileIdstringinference_profile_idstrinferenceProfileIdStringInferenceProfileIdstringInferenceProfileId*string#
The unique identifier of the application inference profile.
inferenceProfileModelIBedrockInvokableinference_profile_modelIBedrockInvokableinferenceProfileModelIBedrockInvokableInferenceProfileModelIBedrockInvokableInferenceProfileModelIBedrockInvokable#
The underlying model/cross-region model used by the application inference profile.
inferenceProfileNamestringinference_profile_namestrinferenceProfileNameStringInferenceProfileNamestringInferenceProfileName*string#
The name of the application inference profile.
invokableArnstringinvokable_arnstrinvokableArnStringInvokableArnstringInvokableArn*string#
The ARN used for invoking this inference profile.

This equals to the inferenceProfileArn property, useful for implementing IBedrockInvokable interface.

nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringstatic#
Uniquely identifies this class.
stackStackstackStackstackStackStackStackStackStack#
The stack in which this resource is defined.
statusstringstatusstrstatusStringStatusstringStatus*string#
The status of the application inference profile.

ACTIVE means that the inference profile is ready to be used.

The type of the inference profile.

Always APPLICATION for application inference profiles.

updatedAtstringupdated_atstrupdatedAtStringUpdatedAtstringUpdatedAt*string#
Time Stamp for Application Inference Profile update.

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)#
Override the cross-stack reference strength for this resource.
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)#
Apply the given removal policy to this resource.
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).

fromApplicationInferenceProfileAttributes(scope: Construct, id: string, attrs: ApplicationInferenceProfileAttributes): IInferenceProfile@staticmethod def from_application_inference_profile_attributes(scope: Construct, id: str, attrs: ApplicationInferenceProfileAttributes) -> IInferenceProfilepublic static IInferenceProfile fromApplicationInferenceProfileAttributes(Construct scope, String id, ApplicationInferenceProfileAttributes attrs)public static IInferenceProfile FromApplicationInferenceProfileAttributes(Construct scope, string id, ApplicationInferenceProfileAttributes attrs)func FromApplicationInferenceProfileAttributes(Scope Construct, Id *string, Attrs ApplicationInferenceProfileAttributes) IInferenceProfilestatic#
Import an Application Inference Profile given its attributes.

[disable-awslint:no-grants]

3 parameters · returns

Parameters

  • scopescopescopescopeScope — - The construct scope.
  • ididididId — - Identifier of the construct.
  • attrsattrsattrsattrsAttrs — - Attributes of the existing application inference profile.

Returns: An IInferenceProfile reference to the existing application inference profile

fromCfnApplicationInferenceProfile(cfnApplicationInferenceProfile: CfnApplicationInferenceProfile): IInferenceProfile@staticmethod def from_cfn_application_inference_profile(cfn_application_inference_profile: CfnApplicationInferenceProfile) -> IInferenceProfilepublic static IInferenceProfile fromCfnApplicationInferenceProfile(CfnApplicationInferenceProfile cfnApplicationInferenceProfile)public static IInferenceProfile FromCfnApplicationInferenceProfile(CfnApplicationInferenceProfile cfnApplicationInferenceProfile)func FromCfnApplicationInferenceProfile(CfnApplicationInferenceProfile CfnApplicationInferenceProfile) IInferenceProfilestatic#
Import a low-level L1 Cfn Application Inference Profile.

[disable-awslint:no-grants]

1 parameter · returns

Parameters

  • cfnApplicationInferenceProfilecfn_application_inference_profilecfnApplicationInferenceProfilecfnApplicationInferenceProfileCfnApplicationInferenceProfile — - The L1 CfnApplicationInferenceProfile to import.

Returns: An IInferenceProfile reference to the imported application inference profile

grantInvoke(grantee: IGrantable): Grantdef grant_invoke(self, grantee: IGrantable) -> Grantpublic Grant grantInvoke(IGrantable grantee)public Grant GrantInvoke(IGrantable grantee)func GrantInvoke(Grantee IGrantable) Grant#
Gives the appropriate policies to invoke and use the application inference profile.

This method ensures the appropriate permissions are given to use either the inference profile or the underlying foundation model/cross-region profile. [disable-awslint:no-grants]

1 parameter · returns

Parameters

  • granteegranteegranteegranteeGrantee — - The IAM principal to grant permissions to.

Returns: An IAM Grant object representing the granted permissions

grantProfileUsage(grantee: IGrantable): Grantdef grant_profile_usage(self, grantee: IGrantable) -> Grantpublic Grant grantProfileUsage(IGrantable grantee)public Grant GrantProfileUsage(IGrantable grantee)func GrantProfileUsage(Grantee IGrantable) Grant#
Grants appropriate permissions to use the application inference profile (AIP).
notes · 1 parameter · returns

This method adds the necessary IAM permissions to allow the grantee to:

  • Get inference profile details (bedrock:GetInferenceProfile)
  • Invoke the model through the inference profile (bedrock:InvokeModel)

Note: This does not grant permissions to use the underlying model/cross-region profile in the AIP. For comprehensive permissions, use grantInvoke() instead. [disable-awslint:no-grants]

Parameters

  • granteegranteegranteegranteeGrantee — - The IAM principal to grant 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#
Checks if `x` is a construct.
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#
Returns true if the construct was created by CDK, and false otherwise.
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#
Check whether the given construct is a Resource.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

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.