def delete_ca()

in deployment_lambda/lambda_function.py [0:0]


def delete_ca(ca_arn):
    iot = boto3.client('iot')
    # TODO: handle multiple page of CAs and Tags
    ca_certs = iot.list_ca_certificates()
    for cert in ca_certs['certificates']:
        response = iot.list_tags_for_resource(resourceArn=cert['certificateArn'])
        for tag in response['tags']:
            if tag['Key'] == ACMPCA_TAG and tag['Value'] == ca_arn:
                iot.update_ca_certificate(certificateId=cert['certificateId'], newStatus='INACTIVE')
                iot.delete_ca_certificate(certificateId=cert['certificateId'])
                break