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
// 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',
});
# 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"
)
// 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();
// 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"
});
// 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
new ApplicationInferenceProfile(scope: Construct, id: string, props: ApplicationInferenceProfileProps)
ApplicationInferenceProfile(scope: Construct, id: str, props: ApplicationInferenceProfileProps)
new ApplicationInferenceProfile(Construct scope, String id, ApplicationInferenceProfileProps props)
new ApplicationInferenceProfile(Construct scope, string id, ApplicationInferenceProfileProps props)
NewApplicationInferenceProfile(Scope Construct, Id *string, Props ApplicationInferenceProfileProps)
Construct Props
applicationInferenceProfileNamestringapplication_inference_profile_namestrapplicationInferenceProfileNameStringApplicationInferenceProfileNamestringApplicationInferenceProfileName*stringrequired#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#Default: No description is provided
- Maximum length: 200 characters when provided
- Pattern:
^([0-9a-zA-Z:.][ _-]?)+$
modelSourceIBedrockInvokablemodel_sourceIBedrockInvokablemodelSourceIBedrockInvokableModelSourceIBedrockInvokableModelSourceIBedrockInvokablerequired#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#Default: No tags are applied
Tags help you organize and categorize your AWS resources.
Properties
envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironment#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#inferenceProfileIdstringinference_profile_idstrinferenceProfileIdStringInferenceProfileIdstringInferenceProfileId*string#inferenceProfileModelIBedrockInvokableinference_profile_modelIBedrockInvokableinferenceProfileModelIBedrockInvokableInferenceProfileModelIBedrockInvokableInferenceProfileModelIBedrockInvokable#inferenceProfileNamestringinference_profile_namestrinferenceProfileNameStringInferenceProfileNamestringInferenceProfileName*string#This equals to the inferenceProfileArn property, useful for implementing IBedrockInvokable interface.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringstatic#ACTIVE means that the inference profile is ready to be used.
typeInferenceProfileTypetypeInferenceProfileTypetypeInferenceProfileTypeTypeInferenceProfileTypeTypeInferenceProfileType#Always APPLICATION for application inference profiles.
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).
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#[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#[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#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#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#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#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.