1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package mwaa
4
5import (
6	"context"
7	"fmt"
8	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
9	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
10	"github.com/aws/aws-sdk-go-v2/service/mwaa/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Creates an Amazon Managed Workflows for Apache Airflow (MWAA) environment.
16func (c *Client) CreateEnvironment(ctx context.Context, params *CreateEnvironmentInput, optFns ...func(*Options)) (*CreateEnvironmentOutput, error) {
17	if params == nil {
18		params = &CreateEnvironmentInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "CreateEnvironment", params, optFns, c.addOperationCreateEnvironmentMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*CreateEnvironmentOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31// This section contains the Amazon Managed Workflows for Apache Airflow (MWAA) API
32// reference documentation to create an environment. For more information, see Get
33// started with Amazon Managed Workflows for Apache Airflow
34// (https://docs.aws.amazon.com/mwaa/latest/userguide/get-started.html).
35type CreateEnvironmentInput struct {
36
37	// The relative path to the DAGs folder on your Amazon S3 bucket. For example,
38	// dags. To learn more, see Adding or updating DAGs
39	// (https://docs.aws.amazon.com/mwaa/latest/userguide/configuring-dag-folder.html).
40	//
41	// This member is required.
42	DagS3Path *string
43
44	// The Amazon Resource Name (ARN) of the execution role for your environment. An
45	// execution role is an AWS Identity and Access Management (IAM) role that grants
46	// MWAA permission to access AWS services and resources used by your environment.
47	// For example, arn:aws:iam::123456789:role/my-execution-role. To learn more, see
48	// Amazon MWAA Execution role
49	// (https://docs.aws.amazon.com/mwaa/latest/userguide/mwaa-create-role.html).
50	//
51	// This member is required.
52	ExecutionRoleArn *string
53
54	// The name of the Amazon MWAA environment. For example, MyMWAAEnvironment.
55	//
56	// This member is required.
57	Name *string
58
59	// The VPC networking components used to secure and enable network traffic between
60	// the AWS resources for your environment. To learn more, see About networking on
61	// Amazon MWAA
62	// (https://docs.aws.amazon.com/mwaa/latest/userguide/networking-about.html).
63	//
64	// This member is required.
65	NetworkConfiguration *types.NetworkConfiguration
66
67	// The Amazon Resource Name (ARN) of the Amazon S3 bucket where your DAG code and
68	// supporting files are stored. For example,
69	// arn:aws:s3:::my-airflow-bucket-unique-name. To learn more, see Create an Amazon
70	// S3 bucket for Amazon MWAA
71	// (https://docs.aws.amazon.com/mwaa/latest/userguide/mwaa-s3-bucket.html).
72	//
73	// This member is required.
74	SourceBucketArn *string
75
76	// A list of key-value pairs containing the Apache Airflow configuration options
77	// you want to attach to your environment. To learn more, see Apache Airflow
78	// configuration options
79	// (https://docs.aws.amazon.com/mwaa/latest/userguide/configuring-env-variables.html).
80	AirflowConfigurationOptions map[string]string
81
82	// The Apache Airflow version for your environment. For example, v1.10.12. If no
83	// value is specified, defaults to the latest version. Valid values: v1.10.12.
84	AirflowVersion *string
85
86	// The environment class type. Valid values: mw1.small, mw1.medium, mw1.large. To
87	// learn more, see Amazon MWAA environment class
88	// (https://docs.aws.amazon.com/mwaa/latest/userguide/environment-class.html).
89	EnvironmentClass *string
90
91	// The AWS Key Management Service (KMS) key to encrypt the data in your
92	// environment. You can use an AWS owned CMK, or a Customer managed CMK (advanced).
93	// To learn more, see Get started with Amazon Managed Workflows for Apache Airflow
94	// (https://docs.aws.amazon.com/mwaa/latest/userguide/get-started.html).
95	KmsKey *string
96
97	// Defines the Apache Airflow logs to send to CloudWatch Logs: DagProcessingLogs,
98	// SchedulerLogs, TaskLogs, WebserverLogs, WorkerLogs.
99	LoggingConfiguration *types.LoggingConfigurationInput
100
101	// The maximum number of workers that you want to run in your environment. MWAA
102	// scales the number of Apache Airflow workers up to the number you specify in the
103	// MaxWorkers field. For example, 20. When there are no more tasks running, and no
104	// more in the queue, MWAA disposes of the extra workers leaving the one worker
105	// that is included with your environment, or the number you specify in MinWorkers.
106	MaxWorkers *int32
107
108	// The minimum number of workers that you want to run in your environment. MWAA
109	// scales the number of Apache Airflow workers up to the number you specify in the
110	// MaxWorkers field. When there are no more tasks running, and no more in the
111	// queue, MWAA disposes of the extra workers leaving the worker count you specify
112	// in the MinWorkers field. For example, 2.
113	MinWorkers *int32
114
115	// The version of the plugins.zip file on your Amazon S3 bucket. A version must be
116	// specified each time a plugins.zip file is updated. To learn more, see How S3
117	// Versioning works
118	// (https://docs.aws.amazon.com/AmazonS3/latest/userguide/versioning-workflows.html).
119	PluginsS3ObjectVersion *string
120
121	// The relative path to the plugins.zip file on your Amazon S3 bucket. For example,
122	// plugins.zip. If specified, then the plugins.zip version is required. To learn
123	// more, see Installing custom plugins
124	// (https://docs.aws.amazon.com/mwaa/latest/userguide/configuring-dag-import-plugins.html).
125	PluginsS3Path *string
126
127	// The version of the requirements.txt file on your Amazon S3 bucket. A version
128	// must be specified each time a requirements.txt file is updated. To learn more,
129	// see How S3 Versioning works
130	// (https://docs.aws.amazon.com/AmazonS3/latest/userguide/versioning-workflows.html).
131	RequirementsS3ObjectVersion *string
132
133	// The relative path to the requirements.txt file on your Amazon S3 bucket. For
134	// example, requirements.txt. If specified, then a file version is required. To
135	// learn more, see Installing Python dependencies
136	// (https://docs.aws.amazon.com/mwaa/latest/userguide/working-dags-dependencies.html).
137	RequirementsS3Path *string
138
139	// The number of Apache Airflow schedulers to run in your environment.
140	Schedulers *int32
141
142	// The key-value tag pairs you want to associate to your environment. For example,
143	// "Environment": "Staging". To learn more, see Tagging AWS resources
144	// (https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html).
145	Tags map[string]string
146
147	// The Apache Airflow Web server access mode. To learn more, see Apache Airflow
148	// access modes
149	// (https://docs.aws.amazon.com/mwaa/latest/userguide/configuring-networking.html).
150	WebserverAccessMode types.WebserverAccessMode
151
152	// The day and time of the week to start weekly maintenance updates of your
153	// environment in the following format: DAY:HH:MM. For example: TUE:03:30. You can
154	// specify a start time in 30 minute increments only. Supported input includes the
155	// following:
156	//
157	// * MON|TUE|WED|THU|FRI|SAT|SUN:([01]\\d|2[0-3]):(00|30)
158	WeeklyMaintenanceWindowStart *string
159
160	noSmithyDocumentSerde
161}
162
163type CreateEnvironmentOutput struct {
164
165	// The Amazon Resource Name (ARN) returned in the response for the environment.
166	Arn *string
167
168	// Metadata pertaining to the operation's result.
169	ResultMetadata middleware.Metadata
170
171	noSmithyDocumentSerde
172}
173
174func (c *Client) addOperationCreateEnvironmentMiddlewares(stack *middleware.Stack, options Options) (err error) {
175	err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateEnvironment{}, middleware.After)
176	if err != nil {
177		return err
178	}
179	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateEnvironment{}, middleware.After)
180	if err != nil {
181		return err
182	}
183	if err = addSetLoggerMiddleware(stack, options); err != nil {
184		return err
185	}
186	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
187		return err
188	}
189	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
190		return err
191	}
192	if err = addResolveEndpointMiddleware(stack, options); err != nil {
193		return err
194	}
195	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
196		return err
197	}
198	if err = addRetryMiddlewares(stack, options); err != nil {
199		return err
200	}
201	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
202		return err
203	}
204	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
205		return err
206	}
207	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
208		return err
209	}
210	if err = addClientUserAgent(stack); err != nil {
211		return err
212	}
213	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
214		return err
215	}
216	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
217		return err
218	}
219	if err = addEndpointPrefix_opCreateEnvironmentMiddleware(stack); err != nil {
220		return err
221	}
222	if err = addOpCreateEnvironmentValidationMiddleware(stack); err != nil {
223		return err
224	}
225	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateEnvironment(options.Region), middleware.Before); err != nil {
226		return err
227	}
228	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
229		return err
230	}
231	if err = addResponseErrorMiddleware(stack); err != nil {
232		return err
233	}
234	if err = addRequestResponseLogging(stack, options); err != nil {
235		return err
236	}
237	return nil
238}
239
240type endpointPrefix_opCreateEnvironmentMiddleware struct {
241}
242
243func (*endpointPrefix_opCreateEnvironmentMiddleware) ID() string {
244	return "EndpointHostPrefix"
245}
246
247func (m *endpointPrefix_opCreateEnvironmentMiddleware) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
248	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
249) {
250	if smithyhttp.GetHostnameImmutable(ctx) || smithyhttp.IsEndpointHostPrefixDisabled(ctx) {
251		return next.HandleSerialize(ctx, in)
252	}
253
254	req, ok := in.Request.(*smithyhttp.Request)
255	if !ok {
256		return out, metadata, fmt.Errorf("unknown transport type %T", in.Request)
257	}
258
259	req.URL.Host = "api." + req.URL.Host
260
261	return next.HandleSerialize(ctx, in)
262}
263func addEndpointPrefix_opCreateEnvironmentMiddleware(stack *middleware.Stack) error {
264	return stack.Serialize.Insert(&endpointPrefix_opCreateEnvironmentMiddleware{}, `OperationSerializer`, middleware.After)
265}
266
267func newServiceMetadataMiddleware_opCreateEnvironment(region string) *awsmiddleware.RegisterServiceMetadata {
268	return &awsmiddleware.RegisterServiceMetadata{
269		Region:        region,
270		ServiceID:     ServiceID,
271		SigningName:   "airflow",
272		OperationName: "CreateEnvironment",
273	}
274}
275