delete_trail.cpp - AWS Code Sample


delete_trail.cpp demonstrates how to delete an AWS CloudTrail resource using command-line input.

/* Copyright 2010-2019, Inc. or its affiliates. All Rights Reserved. This file is licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include <aws/core/Aws.h> #include <aws/core/utils/Outcome.h> #include <aws/cloudtrail/CloudTrailClient.h> #include <aws/cloudtrail/model/DeleteTrailRequest.h> #include <aws/cloudtrail/model/DeleteTrailResult.h> #include <iostream> /** * Deletes a cloud trail on command line input */ int main(int argc, char **argv) { if (argc != 2) { std::cout << "Usage: delete_trail <trail_name>"; return 1; } Aws::SDKOptions options; Aws::InitAPI(options); { Aws::String trail_name(argv[1]); Aws::CloudTrail::CloudTrailClient ct; Aws::CloudTrail::Model::DeleteTrailRequest dt_req; dt_req.SetName(trail_name); auto dt_out = ct.DeleteTrail(dt_req); if (dt_out.IsSuccess()) { std::cout << "Successfully deleted cloud trail" << std::endl; } else { std::cout << "Error deleting cloud trail " << dt_out.GetError().GetMessage() << std::endl; } } Aws::ShutdownAPI(options); return 0; }

Sample Details

Service: cloudtrail

Author: tapasweni-pathak

Type: full-example