1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package opsworks
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/opsworks/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Creates an app for a specified stack. For more information, see Creating Apps
15// (https://docs.aws.amazon.com/opsworks/latest/userguide/workingapps-creating.html).
16// Required Permissions: To use this action, an IAM user must have a Manage
17// permissions level for the stack, or an attached policy that explicitly grants
18// permissions. For more information on user permissions, see Managing User
19// Permissions
20// (https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html).
21func (c *Client) CreateApp(ctx context.Context, params *CreateAppInput, optFns ...func(*Options)) (*CreateAppOutput, error) {
22	if params == nil {
23		params = &CreateAppInput{}
24	}
25
26	result, metadata, err := c.invokeOperation(ctx, "CreateApp", params, optFns, addOperationCreateAppMiddlewares)
27	if err != nil {
28		return nil, err
29	}
30
31	out := result.(*CreateAppOutput)
32	out.ResultMetadata = metadata
33	return out, nil
34}
35
36type CreateAppInput struct {
37
38	// The app name.
39	//
40	// This member is required.
41	Name *string
42
43	// The stack ID.
44	//
45	// This member is required.
46	StackId *string
47
48	// The app type. Each supported type is associated with a particular layer. For
49	// example, PHP applications are associated with a PHP layer. AWS OpsWorks Stacks
50	// deploys an application to those instances that are members of the corresponding
51	// layer. If your app isn't one of the standard types, or you prefer to implement
52	// your own Deploy recipes, specify other.
53	//
54	// This member is required.
55	Type types.AppType
56
57	// A Source object that specifies the app repository.
58	AppSource *types.Source
59
60	// One or more user-defined key/value pairs to be added to the stack attributes.
61	Attributes map[string]string
62
63	// The app's data source.
64	DataSources []types.DataSource
65
66	// A description of the app.
67	Description *string
68
69	// The app virtual host settings, with multiple domains separated by commas. For
70	// example: 'www.example.com, example.com'
71	Domains []string
72
73	// Whether to enable SSL for the app.
74	EnableSsl *bool
75
76	// An array of EnvironmentVariable objects that specify environment variables to be
77	// associated with the app. After you deploy the app, these variables are defined
78	// on the associated app server instance. For more information, see  Environment
79	// Variables
80	// (https://docs.aws.amazon.com/opsworks/latest/userguide/workingapps-creating.html#workingapps-creating-environment).
81	// There is no specific limit on the number of environment variables. However, the
82	// size of the associated data structure - which includes the variables' names,
83	// values, and protected flag values - cannot exceed 20 KB. This limit should
84	// accommodate most if not all use cases. Exceeding it will cause an exception with
85	// the message, "Environment: is too large (maximum is 20KB)." If you have
86	// specified one or more environment variables, you cannot modify the stack's Chef
87	// version.
88	Environment []types.EnvironmentVariable
89
90	// The app's short name.
91	Shortname *string
92
93	// An SslConfiguration object with the SSL configuration.
94	SslConfiguration *types.SslConfiguration
95}
96
97// Contains the response to a CreateApp request.
98type CreateAppOutput struct {
99
100	// The app ID.
101	AppId *string
102
103	// Metadata pertaining to the operation's result.
104	ResultMetadata middleware.Metadata
105}
106
107func addOperationCreateAppMiddlewares(stack *middleware.Stack, options Options) (err error) {
108	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateApp{}, middleware.After)
109	if err != nil {
110		return err
111	}
112	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateApp{}, middleware.After)
113	if err != nil {
114		return err
115	}
116	if err = addSetLoggerMiddleware(stack, options); err != nil {
117		return err
118	}
119	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
120		return err
121	}
122	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
123		return err
124	}
125	if err = addResolveEndpointMiddleware(stack, options); err != nil {
126		return err
127	}
128	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
129		return err
130	}
131	if err = addRetryMiddlewares(stack, options); err != nil {
132		return err
133	}
134	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
135		return err
136	}
137	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
138		return err
139	}
140	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
141		return err
142	}
143	if err = addClientUserAgent(stack); err != nil {
144		return err
145	}
146	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
147		return err
148	}
149	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
150		return err
151	}
152	if err = addOpCreateAppValidationMiddleware(stack); err != nil {
153		return err
154	}
155	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateApp(options.Region), middleware.Before); err != nil {
156		return err
157	}
158	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
159		return err
160	}
161	if err = addResponseErrorMiddleware(stack); err != nil {
162		return err
163	}
164	if err = addRequestResponseLogging(stack, options); err != nil {
165		return err
166	}
167	return nil
168}
169
170func newServiceMetadataMiddleware_opCreateApp(region string) *awsmiddleware.RegisterServiceMetadata {
171	return &awsmiddleware.RegisterServiceMetadata{
172		Region:        region,
173		ServiceID:     ServiceID,
174		SigningName:   "opsworks",
175		OperationName: "CreateApp",
176	}
177}
178