Skip to content
v2.275.0

ArnComponents Struct ​

Example ​

ts
import { WebSocketIamAuthorizer } from 'aws-cdk-lib/aws-apigatewayv2-authorizers';
import { WebSocketLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';

// This function handles your connect route
declare const connectHandler: lambda.Function;

const webSocketApi = new apigwv2.WebSocketApi(this, 'WebSocketApi');

webSocketApi.addRoute('$connect', {
  integration: new WebSocketLambdaIntegration('Integration', connectHandler),
  authorizer: new WebSocketIamAuthorizer()
});

// Create an IAM user (identity)
const user = new iam.User(this, 'User');

const webSocketArn = Stack.of(this).formatArn({
  service: 'execute-api',
  resource: webSocketApi.apiId,
});

// Grant access to the IAM user
user.attachInlinePolicy(new iam.Policy(this, 'AllowInvoke', {
  statements: [
    new iam.PolicyStatement({
      actions: ['execute-api:Invoke'],
      effect: iam.Effect.ALLOW,
      resources: [webSocketArn],
    }),
  ],
}));

Properties ​

accountoptionalstringaccountoptionalstraccountoptionalStringAccountoptionalstringAccountoptional*string#
The ID of the AWS account that owns the resource, without the hyphens.

Default: The account the stack is deployed to.

For example, 123456789012. Note that the ARNs for some resources don't require an account number, so this component might be omitted.

arnFormatoptionalArnFormatarn_formatoptionalArnFormatarnFormatoptionalArnFormatArnFormatoptionalArnFormatArnFormatoptionalArnFormat#
The specific ARN format to use for this ARN value.

Default: ':' when arnFormat is COLON_RESOURCE_NAME, '/' otherwise. The deprecated sep property takes precedence when specified.

partitionoptionalstringpartitionoptionalstrpartitionoptionalStringPartitionoptionalstringPartitionoptional*string#
The partition that the resource is in.

Default: The AWS partition the stack is deployed to.

For standard AWS regions, the partition is aws. If you have resources in other partitions, the partition is aws-partitionname. For example, the partition for resources in the China (Beijing) region is aws-cn.

regionoptionalstringregionoptionalstrregionoptionalStringRegionoptionalstringRegionoptional*string#
The region the resource resides in.

Default: The region the stack is deployed to.

Note that the ARNs for some resources do not require a region, so this component might be omitted.

resourcestringresourcestrresourceStringResourcestringResource*stringrequired#
Resource type (e.g. "table", "autoScalingGroup", "certificate"). For some resource types, e.g. S3 buckets, this field defines the bucket name.
resourceNameoptionalstringresource_nameoptionalstrresourceNameoptionalStringResourceNameoptionalstringResourceNameoptional*string#
Resource name or path within the resource (i.e. S3 bucket object key) or a wildcard such as ``"*"``. This is service-dependent.
servicestringservicestrserviceStringServicestringService*stringrequired#
The service namespace that identifies the AWS product (for example, 's3', 'iam', 'codepipeline').