(aws-iot): CfnProvisioningTemplate Template with name already exists
See original GitHub issueWhat is the problem?
npm package version : 1.132.0 & 1.135.0 (tried with these two)
when creating a iot Provisioning Template using cdk, the following error is thrown:
Template with name provisioningtemplate_JAoF84L77Jaf already exists (Service: Iot, Status Code: 409, Request ID: 60a18fc4-8778-4f73-b5d2-9589e37f3d43, Extended Request ID: null)`
N.B. it does not matter if we provide a template name or let cdk choose a name as seen above N.B. the stack is being newly created and so there is NO provisioning template existing whatsoever
Reproduction Steps
use similar code as:
import * as iam from '@aws-cdk/aws-iam';
import * as iot from '@aws-cdk/aws-iot';
const provisioningRole = new iam.Role(this, 'provisioning-role-arn', {
assumedBy : new iam.ServicePrincipal('iot.amazonaws.com'),
description : 'Role assumed by provisioning template to bulk provision devices by claim',
roleName : `ProvisioningByClaimRole`,
managedPolicies : [iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSIoTThingsRegistration')],
});
const provisioningTemplate = new iot.CfnProvisioningTemplate(this, 'provisioning-template', {
provisioningRoleArn : provisioningRole.roleArn,
templateBody : JSON.stringify(provisioningTemplateBody),
description : 'provision by claim template for guard devices that use certificates for authentication',
enabled : false,
preProvisioningHook : {
targetArn : preProvisioningHookLambda.functionArn,
payloadVersion : '2020-04-01',
},
});
can ignore the preprovisioning hook lambda and template if needed
What did you expect to happen?
since the current stack is the one initiating the creation of the provisioning template, then it should create the template resource without error
What actually happened?
the stack ACTUALLY creates the iot provisioning template resource completely but then throws the name conflict error and fails. Meaning after the stack completes the rollback, there is the new provisioning templete resource in iot.
CDK CLI Version
1.135.0
Framework Version
No response
Node.js Version
14.18.1
OS
macOS Big Sur 11.6.1
Language
Typescript
Language Version
4.3.2
Other information
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
@skinny85 Sure. Here is the template body:
The
fleetIoTPolicy
is an instance of CfnPolicy.⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.