1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package cloudformation 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/aws-sdk-go-v2/service/cloudformation/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Validates a specified template. AWS CloudFormation first checks if the template 15// is valid JSON. If it isn't, AWS CloudFormation checks if the template is valid 16// YAML. If both these checks fail, AWS CloudFormation returns a template 17// validation error. 18func (c *Client) ValidateTemplate(ctx context.Context, params *ValidateTemplateInput, optFns ...func(*Options)) (*ValidateTemplateOutput, error) { 19 if params == nil { 20 params = &ValidateTemplateInput{} 21 } 22 23 result, metadata, err := c.invokeOperation(ctx, "ValidateTemplate", params, optFns, addOperationValidateTemplateMiddlewares) 24 if err != nil { 25 return nil, err 26 } 27 28 out := result.(*ValidateTemplateOutput) 29 out.ResultMetadata = metadata 30 return out, nil 31} 32 33// The input for ValidateTemplate action. 34type ValidateTemplateInput struct { 35 36 // Structure containing the template body with a minimum length of 1 byte and a 37 // maximum length of 51,200 bytes. For more information, go to Template Anatomy 38 // (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html) 39 // in the AWS CloudFormation User Guide. Conditional: You must pass TemplateURL or 40 // TemplateBody. If both are passed, only TemplateBody is used. 41 TemplateBody *string 42 43 // Location of file containing the template body. The URL must point to a template 44 // (max size: 460,800 bytes) that is located in an Amazon S3 bucket or a Systems 45 // Manager document. For more information, go to Template Anatomy 46 // (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html) 47 // in the AWS CloudFormation User Guide. Conditional: You must pass TemplateURL or 48 // TemplateBody. If both are passed, only TemplateBody is used. 49 TemplateURL *string 50} 51 52// The output for ValidateTemplate action. 53type ValidateTemplateOutput struct { 54 55 // The capabilities found within the template. If your template contains IAM 56 // resources, you must specify the CAPABILITY_IAM or CAPABILITY_NAMED_IAM value for 57 // this parameter when you use the CreateStack or UpdateStack actions with your 58 // template; otherwise, those actions return an InsufficientCapabilities error. For 59 // more information, see Acknowledging IAM Resources in AWS CloudFormation 60 // Templates 61 // (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-iam-template.html#capabilities). 62 Capabilities []types.Capability 63 64 // The list of resources that generated the values in the Capabilities response 65 // element. 66 CapabilitiesReason *string 67 68 // A list of the transforms that are declared in the template. 69 DeclaredTransforms []string 70 71 // The description found within the template. 72 Description *string 73 74 // A list of TemplateParameter structures. 75 Parameters []types.TemplateParameter 76 77 // Metadata pertaining to the operation's result. 78 ResultMetadata middleware.Metadata 79} 80 81func addOperationValidateTemplateMiddlewares(stack *middleware.Stack, options Options) (err error) { 82 err = stack.Serialize.Add(&awsAwsquery_serializeOpValidateTemplate{}, middleware.After) 83 if err != nil { 84 return err 85 } 86 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpValidateTemplate{}, middleware.After) 87 if err != nil { 88 return err 89 } 90 if err = addSetLoggerMiddleware(stack, options); err != nil { 91 return err 92 } 93 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 94 return err 95 } 96 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 97 return err 98 } 99 if err = addResolveEndpointMiddleware(stack, options); err != nil { 100 return err 101 } 102 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 103 return err 104 } 105 if err = addRetryMiddlewares(stack, options); err != nil { 106 return err 107 } 108 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 109 return err 110 } 111 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 112 return err 113 } 114 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 115 return err 116 } 117 if err = addClientUserAgent(stack); err != nil { 118 return err 119 } 120 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 121 return err 122 } 123 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 124 return err 125 } 126 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opValidateTemplate(options.Region), middleware.Before); err != nil { 127 return err 128 } 129 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 130 return err 131 } 132 if err = addResponseErrorMiddleware(stack); err != nil { 133 return err 134 } 135 if err = addRequestResponseLogging(stack, options); err != nil { 136 return err 137 } 138 return nil 139} 140 141func newServiceMetadataMiddleware_opValidateTemplate(region string) *awsmiddleware.RegisterServiceMetadata { 142 return &awsmiddleware.RegisterServiceMetadata{ 143 Region: region, 144 ServiceID: ServiceID, 145 SigningName: "cloudformation", 146 OperationName: "ValidateTemplate", 147 } 148} 149