DeleteParameter.go - AWS Code Sample

DeleteParameter.go

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: MIT-0 package main import ( "flag" "fmt" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ssm" "github.com/aws/aws-sdk-go/service/ssm/ssmiface" ) // DeleteParameter deletes a parameter in SSM // Inputs: // svc is an Amazon SSM service client // name is the name of the parameter // Output: // If success, return nil // Otherwise, error from the call to DeleteParameter func DeleteParameter(svc ssmiface.SSMAPI, name *string) error { _, err := svc.DeleteParameter(&ssm.DeleteParameterInput{ Name: name, }) return err } func main() { parameterName := flag.String("n", "", "The name of the parameter") flag.Parse() if *parameterName == "" { fmt.Println("You must supply the name of the parameter") fmt.Println("-n NAME") return } sess := session.Must(session.NewSessionWithOptions(session.Options{ SharedConfigState: session.SharedConfigEnable, })) svc := ssm.New(sess) err := DeleteParameter(svc, parameterName) if err != nil { fmt.Println(err.Error()) return } }