interface AwsCustomResourceProps
Language | Type name |
---|---|
![]() | Amazon.CDK.CustomResources.AwsCustomResourceProps |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/customresources#AwsCustomResourceProps |
![]() | software.amazon.awscdk.customresources.AwsCustomResourceProps |
![]() | aws_cdk.custom_resources.AwsCustomResourceProps |
![]() | aws-cdk-lib » custom_resources » AwsCustomResourceProps |
Properties for AwsCustomResource.
Note that at least onCreate, onUpdate or onDelete must be specified.
Example
const getParameter = new cr.AwsCustomResource(this, 'GetParameter', {
onUpdate: { // will also be called for a CREATE event
service: 'SSM',
action: 'GetParameter',
parameters: {
Name: 'my-parameter',
WithDecryption: true,
},
physicalResourceId: cr.PhysicalResourceId.of(Date.now().toString()), // Update physical id to always fetch the latest version
},
policy: cr.AwsCustomResourcePolicy.fromSdkCalls({
resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE,
}),
});
// Use the value in another construct with
getParameter.getResponseField('Parameter.Value');
Properties
Name | Type | Description |
---|---|---|
function | string | A name for the singleton Lambda function implementing this custom resource. |
install | boolean | Whether to install the latest AWS SDK v2. |
log | ILog | The Log Group used for logging of events emitted by the custom resource's lambda function. |
log | Retention | The number of days log events of the singleton Lambda function implementing this custom resource are kept in CloudWatch Logs. |
memory | number | The memory size for the singleton Lambda function implementing this custom resource. |
on | Aws | The AWS SDK call to make when the resource is created. |
on | Aws | The AWS SDK call to make when the resource is deleted. |
on | Aws | The AWS SDK call to make when the resource is updated. |
policy? | Aws | The policy that will be added to the execution role of the Lambda function implementing this custom resource provider. |
removal | Removal | The policy to apply when this resource is removed from the application. |
resource | string | Cloudformation Resource type. |
role? | IRole | The execution role for the singleton Lambda function implementing this custom resource provider. |
service | Duration | The maximum time that can elapse before a custom resource operation times out. |
timeout? | Duration | The timeout for the singleton Lambda function implementing this custom resource. |
vpc? | IVpc | The vpc to provision the lambda function in. |
vpc | Subnet | Which subnets from the VPC to place the lambda function in. |
functionName?
Type:
string
(optional, default: AWS CloudFormation generates a unique physical ID and uses that
ID for the function's name. For more information, see Name Type.)
A name for the singleton Lambda function implementing this custom resource.
The function name will remain the same after the first AwsCustomResource is created in a stack.
installLatestAwsSdk?
Type:
boolean
(optional, default: The value of @aws-cdk/customresources:installLatestAwsSdkDefault
, otherwise true
)
Whether to install the latest AWS SDK v2.
If not specified, this uses whatever JavaScript SDK version is the default in AWS Lambda at the time of execution.
Otherwise, installs the latest version from 'npmjs.com'. The installation takes around 60 seconds and requires internet connectivity.
The default can be controlled using the context key
@aws-cdk/customresources:installLatestAwsSdkDefault
is.
logGroup?
Type:
ILog
(optional, default: a default log group created by AWS Lambda)
The Log Group used for logging of events emitted by the custom resource's lambda function.
Providing a user-controlled log group was rolled out to commercial regions on 2023-11-16. If you are deploying to another type of region, please check regional availability first.
logRetention?
Type:
Retention
(optional, default: logs.RetentionDays.INFINITE)
The number of days log events of the singleton Lambda function implementing this custom resource are kept in CloudWatch Logs.
This is a legacy API and we strongly recommend you migrate to logGroup
if you can.
logGroup
allows you to create a fully customizable log group and instruct the Lambda function to send logs to it.
memorySize?
Type:
number
(optional, default: 512 mega in case if installLatestAwsSdk is false.)
The memory size for the singleton Lambda function implementing this custom resource.
onCreate?
Type:
Aws
(optional, default: the call when the resource is updated)
The AWS SDK call to make when the resource is created.
onDelete?
Type:
Aws
(optional, default: no call)
The AWS SDK call to make when the resource is deleted.
onUpdate?
Type:
Aws
(optional, default: no call)
The AWS SDK call to make when the resource is updated.
policy?
Type:
Aws
(optional, default: no policy added)
The policy that will be added to the execution role of the Lambda function implementing this custom resource provider.
The custom resource also implements iam.IGrantable
, making it possible
to use the grantXxx()
methods.
As this custom resource uses a singleton Lambda function, it's important to note the that function's role will eventually accumulate the permissions/grants from all resources.
Note that a policy must be specified if role
is not provided, as
by default a new role is created which requires policy changes to access
resources.
See also: Policy.fromSdkCalls
removalPolicy?
Type:
Removal
(optional, default: cdk.RemovalPolicy.Destroy)
The policy to apply when this resource is removed from the application.
resourceType?
Type:
string
(optional, default: Custom::AWS)
Cloudformation Resource type.
role?
Type:
IRole
(optional, default: a new role is created)
The execution role for the singleton Lambda function implementing this custom resource provider.
This role will apply to all AwsCustomResource
instances in the stack. The role must be assumable by the
lambda.amazonaws.com
service principal.
serviceTimeout?
Type:
Duration
(optional, default: Duration.seconds(3600))
The maximum time that can elapse before a custom resource operation times out.
You should not need to set this property. It is intended to allow quick turnaround
even if the implementor of the custom resource forgets to include a try/catch
.
We have included the try/catch
, and AWS service calls usually do not take an hour
to complete.
The value must be between 1 second and 3600 seconds.
timeout?
Type:
Duration
(optional, default: Duration.minutes(2))
The timeout for the singleton Lambda function implementing this custom resource.
vpc?
Type:
IVpc
(optional, default: the function is not provisioned inside a vpc.)
The vpc to provision the lambda function in.
vpcSubnets?
Type:
Subnet
(optional, default: the Vpc default strategy if not specified)
Which subnets from the VPC to place the lambda function in.
Only used if 'vpc' is supplied. Note: internet access for Lambdas requires a NAT gateway, so picking Public subnets is not allowed.