1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package batch 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/batch/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Creates an AWS Batch compute environment. You can create MANAGED or UNMANAGED 15// compute environments. MANAGED compute environments can use Amazon EC2 or AWS 16// Fargate resources. UNMANAGED compute environments can only use EC2 resources. In 17// a managed compute environment, AWS Batch manages the capacity and instance types 18// of the compute resources within the environment. This is based on the compute 19// resource specification that you define or the launch template 20// (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html) 21// that you specify when you create the compute environment. Either, you can choose 22// to use EC2 On-Demand Instances and EC2 Spot Instances. Or, you can use Fargate 23// and Fargate Spot capacity in your managed compute environment. You can 24// optionally set a maximum price so that Spot Instances only launch when the Spot 25// Instance price is less than a specified percentage of the On-Demand price. 26// Multi-node parallel jobs aren't supported on Spot Instances. In an unmanaged 27// compute environment, you can manage your own EC2 compute resources and have a 28// lot of flexibility with how you configure your compute resources. For example, 29// you can use custom AMIs. However, you must verify that each of your AMIs meet 30// the Amazon ECS container instance AMI specification. For more information, see 31// container instance AMIs 32// (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/container_instance_AMIs.html) 33// in the Amazon Elastic Container Service Developer Guide. After you created your 34// unmanaged compute environment, you can use the DescribeComputeEnvironments 35// operation to find the Amazon ECS cluster that's associated with it. Then, launch 36// your container instances into that Amazon ECS cluster. For more information, see 37// Launching an Amazon ECS container instance 38// (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_container_instance.html) 39// in the Amazon Elastic Container Service Developer Guide. AWS Batch doesn't 40// upgrade the AMIs in a compute environment after the environment is created. For 41// example, it doesn't update the AMIs when a newer version of the Amazon ECS 42// optimized AMI is available. Therefore, you're responsible for managing the guest 43// operating system (including its updates and security patches) and any additional 44// application software or utilities that you install on the compute resources. To 45// use a new AMI for your AWS Batch jobs, complete these steps: 46// 47// * Create a new 48// compute environment with the new AMI. 49// 50// * Add the compute environment to an 51// existing job queue. 52// 53// * Remove the earlier compute environment from your job 54// queue. 55// 56// * Delete the earlier compute environment. 57func (c *Client) CreateComputeEnvironment(ctx context.Context, params *CreateComputeEnvironmentInput, optFns ...func(*Options)) (*CreateComputeEnvironmentOutput, error) { 58 if params == nil { 59 params = &CreateComputeEnvironmentInput{} 60 } 61 62 result, metadata, err := c.invokeOperation(ctx, "CreateComputeEnvironment", params, optFns, addOperationCreateComputeEnvironmentMiddlewares) 63 if err != nil { 64 return nil, err 65 } 66 67 out := result.(*CreateComputeEnvironmentOutput) 68 out.ResultMetadata = metadata 69 return out, nil 70} 71 72// Contains the parameters for CreateComputeEnvironment. 73type CreateComputeEnvironmentInput struct { 74 75 // The name for your compute environment. Up to 128 letters (uppercase and 76 // lowercase), numbers, hyphens, and underscores are allowed. 77 // 78 // This member is required. 79 ComputeEnvironmentName *string 80 81 // The type of the compute environment: MANAGED or UNMANAGED. For more information, 82 // see Compute Environments 83 // (https://docs.aws.amazon.com/batch/latest/userguide/compute_environments.html) 84 // in the AWS Batch User Guide. 85 // 86 // This member is required. 87 Type types.CEType 88 89 // Details about the compute resources managed by the compute environment. This 90 // parameter is required for managed compute environments. For more information, 91 // see Compute Environments 92 // (https://docs.aws.amazon.com/batch/latest/userguide/compute_environments.html) 93 // in the AWS Batch User Guide. 94 ComputeResources *types.ComputeResource 95 96 // The full Amazon Resource Name (ARN) of the IAM role that allows AWS Batch to 97 // make calls to other AWS services on your behalf. For more information, see AWS 98 // Batch service IAM role 99 // (https://docs.aws.amazon.com/batch/latest/userguide/service_IAM_role.html) in 100 // the AWS Batch User Guide. If your account has already created the AWS Batch 101 // service-linked role, that role is used by default for your compute environment 102 // unless you specify a role here. If the AWS Batch service-linked role does not 103 // exist in your account, and no role is specified here, the service will try to 104 // create the AWS Batch service-linked role in your account. If your specified role 105 // has a path other than /, then you must specify either the full role ARN 106 // (recommended) or prefix the role name with the path. For example, if a role with 107 // the name bar has a path of /foo/ then you would specify /foo/bar as the role 108 // name. For more information, see Friendly names and paths 109 // (https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-friendly-names) 110 // in the IAM User Guide. Depending on how you created your AWS Batch service role, 111 // its ARN might contain the service-role path prefix. When you only specify the 112 // name of the service role, AWS Batch assumes that your ARN doesn't use the 113 // service-role path prefix. Because of this, we recommend that you specify the 114 // full ARN of your service role when you create compute environments. 115 ServiceRole *string 116 117 // The state of the compute environment. If the state is ENABLED, then the compute 118 // environment accepts jobs from a queue and can scale out automatically based on 119 // queues. If the state is ENABLED, then the AWS Batch scheduler can attempt to 120 // place jobs from an associated job queue on the compute resources within the 121 // environment. If the compute environment is managed, then it can scale its 122 // instances out or in automatically, based on the job queue demand. If the state 123 // is DISABLED, then the AWS Batch scheduler doesn't attempt to place jobs within 124 // the environment. Jobs in a STARTING or RUNNING state continue to progress 125 // normally. Managed compute environments in the DISABLED state don't scale out. 126 // However, they scale in to minvCpus value after instances become idle. 127 State types.CEState 128 129 // The tags that you apply to the compute environment to help you categorize and 130 // organize your resources. Each tag consists of a key and an optional value. For 131 // more information, see Tagging AWS Resources 132 // (https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html) in AWS General 133 // Reference. These tags can be updated or removed using the TagResource 134 // (https://docs.aws.amazon.com/batch/latest/APIReference/API_TagResource.html) and 135 // UntagResource 136 // (https://docs.aws.amazon.com/batch/latest/APIReference/API_UntagResource.html) 137 // API operations. These tags don't propagate to the underlying compute resources. 138 Tags map[string]string 139} 140 141type CreateComputeEnvironmentOutput struct { 142 143 // The Amazon Resource Name (ARN) of the compute environment. 144 ComputeEnvironmentArn *string 145 146 // The name of the compute environment. Up to 128 letters (uppercase and 147 // lowercase), numbers, hyphens, and underscores are allowed. 148 ComputeEnvironmentName *string 149 150 // Metadata pertaining to the operation's result. 151 ResultMetadata middleware.Metadata 152} 153 154func addOperationCreateComputeEnvironmentMiddlewares(stack *middleware.Stack, options Options) (err error) { 155 err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateComputeEnvironment{}, middleware.After) 156 if err != nil { 157 return err 158 } 159 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateComputeEnvironment{}, middleware.After) 160 if err != nil { 161 return err 162 } 163 if err = addSetLoggerMiddleware(stack, options); err != nil { 164 return err 165 } 166 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 167 return err 168 } 169 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 170 return err 171 } 172 if err = addResolveEndpointMiddleware(stack, options); err != nil { 173 return err 174 } 175 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 176 return err 177 } 178 if err = addRetryMiddlewares(stack, options); err != nil { 179 return err 180 } 181 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 182 return err 183 } 184 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 185 return err 186 } 187 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 188 return err 189 } 190 if err = addClientUserAgent(stack); err != nil { 191 return err 192 } 193 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 194 return err 195 } 196 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 197 return err 198 } 199 if err = addOpCreateComputeEnvironmentValidationMiddleware(stack); err != nil { 200 return err 201 } 202 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateComputeEnvironment(options.Region), middleware.Before); err != nil { 203 return err 204 } 205 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 206 return err 207 } 208 if err = addResponseErrorMiddleware(stack); err != nil { 209 return err 210 } 211 if err = addRequestResponseLogging(stack, options); err != nil { 212 return err 213 } 214 return nil 215} 216 217func newServiceMetadataMiddleware_opCreateComputeEnvironment(region string) *awsmiddleware.RegisterServiceMetadata { 218 return &awsmiddleware.RegisterServiceMetadata{ 219 Region: region, 220 ServiceID: ServiceID, 221 SigningName: "batch", 222 OperationName: "CreateComputeEnvironment", 223 } 224} 225