SdkCallsPolicyOptions Struct
Options for the auto-generation of policies based on the configured SDK calls.
| Source | custom-resources/lib/aws-custom-resource/aws-custom-resource.ts |
|---|
Example
ts
const getParameter = new cr.AwsCustomResource(this, 'GetParameter', {
onUpdate: {
service: 'SSM',
action: 'GetParameter',
parameters: {
Name: 'my-parameter',
WithDecryption: true,
},
physicalResourceId: cr.PhysicalResourceId.of(Date.now().toString()),
logging: cr.Logging.withDataHidden(),
},
policy: cr.AwsCustomResourcePolicy.fromSdkCalls({
resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE,
}),
});
python
get_parameter = cr.AwsCustomResource(self, "GetParameter",
on_update=cr.AwsSdkCall(
service="SSM",
action="GetParameter",
parameters={
"Name": "my-parameter",
"WithDecryption": True
},
physical_resource_id=cr.PhysicalResourceId.of(Date.now().to_string()),
logging=cr.Logging.with_data_hidden()
),
policy=cr.AwsCustomResourcePolicy.from_sdk_calls(
resources=cr.AwsCustomResourcePolicy.ANY_RESOURCE
)
)
java
AwsCustomResource getParameter = AwsCustomResource.Builder.create(this, "GetParameter")
.onUpdate(AwsSdkCall.builder()
.service("SSM")
.action("GetParameter")
.parameters(Map.of(
"Name", "my-parameter",
"WithDecryption", true))
.physicalResourceId(PhysicalResourceId.of(Date.now().toString()))
.logging(Logging.withDataHidden())
.build())
.policy(AwsCustomResourcePolicy.fromSdkCalls(SdkCallsPolicyOptions.builder()
.resources(AwsCustomResourcePolicy.ANY_RESOURCE)
.build()))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var getParameter = new AwsCustomResource(this, "GetParameter", new AwsCustomResourceProps {
OnUpdate = new AwsSdkCall {
Service = "SSM",
Action = "GetParameter",
Parameters = new Dictionary<string, object> {
{ "Name", "my-parameter" },
{ "WithDecryption", true }
},
PhysicalResourceId = PhysicalResourceId.Of(Date.Now().ToString()),
Logging = Logging.WithDataHidden()
},
Policy = AwsCustomResourcePolicy.FromSdkCalls(new SdkCallsPolicyOptions {
Resources = AwsCustomResourcePolicy.ANY_RESOURCE
})
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
getParameter := cr.NewAwsCustomResource(this, jsii.String("GetParameter"), &AwsCustomResourceProps{
OnUpdate: &AwsSdkCall{
Service: jsii.String("SSM"),
Action: jsii.String("GetParameter"),
Parameters: map[string]interface{}{
"Name": jsii.String("my-parameter"),
"WithDecryption": jsii.Boolean(true),
},
PhysicalResourceId: cr.PhysicalResourceId_Of(date.now().toString()),
Logging: cr.Logging_WithDataHidden(),
},
Policy: cr.AwsCustomResourcePolicy_FromSdkCalls(&SdkCallsPolicyOptions{
Resources: cr.AwsCustomResourcePolicy_ANY_RESOURCE(),
}),
})
Properties
resourcesstring[]resourcestyping.List[str]resourcesList<String>Resourcesstring[]Resources*[]*string required #The resources that the calls will have access to.
notes
It is best to use specific resource ARN's when possible. However, you can also use AwsCustomResourcePolicy.ANY_RESOURCE to allow access to all resources. For example, when onCreate is used to create a resource which you don't know the physical name of in advance.
Note that will apply to ALL SDK calls.