简体   繁体   中英

Multiple actions - AwsCustomResource.on.. Is it possible?

I've created a custom resource for creating a ThingType which is not yet implemented by AWS as simple CfnObjects. My code looks like this:

String physicalResIdThingType = "ThisISMyThing";
AwsCustomResource.Builder.create(this, "myThingType")
                .onCreate(AwsSdkCall.builder()
                        .service("Iot")
                        .action("createThingType")
                        .physicalResourceId(PhysicalResourceId.of(physicalResIdThingType))
                        .parameters(new HashMap() {{
                            put("thingTypeName", "myThingType");
                        }})
                        .build())
                .onDelete(AwsSdkCall.builder()
                        .service("Iot")
                        .action("deleteThingType")
                        .physicalResourceId(PhysicalResourceId.of(physicalResIdThingType))
                        .parameters(new HashMap() {{
                            put("thingTypeName", "myThingType");
                        }}).build())               .policy(AwsCustomResourcePolicy.fromSdkCalls(SdkCallsPolicyOptions.builder()
                        .resources(AwsCustomResourcePolicy.ANY_RESOURCE)
                        .build()))
                .installLatestAwsSdk(false)
                .resourceType(Consts.CUSTOM_RESOURCE_THING_TYPE)
                .build();

It is creating well. but not allowing me to delete the thing type because I need first to deprecate it and then delete it.. In the console we need to wait even 5 minutes after deprecation for complete deletion.

My questions are:

  1. Is it possible to override this deprecation?
  2. If not, Is it possible to do multiple AwsSdkCalls without writing my own lambda functions?
  3. If none from above, then maybe someone has an idea how can I use this simple solution of AwsCustomResource to delete my thing type?

I can only see one way to do it if you want the thing type to be deleted via cloudformation.

You can configure the timeout-in-minutes when call cloudformation crate-stack . This value should be above than 5 minutes + extra buffer for the other resources to be deleted.

When you receive a DELETE event in your custom resource, you can deprecate the thing type, wait 5min and call delete thing type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM