1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package opsworkscm 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/opsworkscm/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Creates and immedately starts a new server. The server is ready to use when it 15// is in the HEALTHY state. By default, you can create a maximum of 10 servers. 16// This operation is asynchronous. A LimitExceededException is thrown when you have 17// created the maximum number of servers (10). A ResourceAlreadyExistsException is 18// thrown when a server with the same name already exists in the account. A 19// ResourceNotFoundException is thrown when you specify a backup ID that is not 20// valid or is for a backup that does not exist. A ValidationException is thrown 21// when parameters of the request are not valid. If you do not specify a security 22// group by adding the SecurityGroupIds parameter, AWS OpsWorks creates a new 23// security group. Chef Automate: The default security group opens the Chef server 24// to the world on TCP port 443. If a KeyName is present, AWS OpsWorks enables SSH 25// access. SSH is also open to the world on TCP port 22. Puppet Enterprise: The 26// default security group opens TCP ports 22, 443, 4433, 8140, 8142, 8143, and 27// 8170. If a KeyName is present, AWS OpsWorks enables SSH access. SSH is also open 28// to the world on TCP port 22. By default, your server is accessible from any IP 29// address. We recommend that you update your security group rules to allow access 30// from known IP addresses and address ranges only. To edit security group rules, 31// open Security Groups in the navigation pane of the EC2 management console. To 32// specify your own domain for a server, and provide your own self-signed or 33// CA-signed certificate and private key, specify values for CustomDomain, 34// CustomCertificate, and CustomPrivateKey. 35func (c *Client) CreateServer(ctx context.Context, params *CreateServerInput, optFns ...func(*Options)) (*CreateServerOutput, error) { 36 if params == nil { 37 params = &CreateServerInput{} 38 } 39 40 result, metadata, err := c.invokeOperation(ctx, "CreateServer", params, optFns, c.addOperationCreateServerMiddlewares) 41 if err != nil { 42 return nil, err 43 } 44 45 out := result.(*CreateServerOutput) 46 out.ResultMetadata = metadata 47 return out, nil 48} 49 50type CreateServerInput struct { 51 52 // The configuration management engine to use. Valid values include ChefAutomate 53 // and Puppet. 54 // 55 // This member is required. 56 Engine *string 57 58 // The ARN of the instance profile that your Amazon EC2 instances use. Although the 59 // AWS OpsWorks console typically creates the instance profile for you, if you are 60 // using API commands instead, run the service-role-creation.yaml AWS 61 // CloudFormation template, located at 62 // https://s3.amazonaws.com/opsworks-cm-us-east-1-prod-default-assets/misc/opsworks-cm-roles.yaml. 63 // This template creates a CloudFormation stack that includes the instance profile 64 // you need. 65 // 66 // This member is required. 67 InstanceProfileArn *string 68 69 // The Amazon EC2 instance type to use. For example, m5.large. 70 // 71 // This member is required. 72 InstanceType *string 73 74 // The name of the server. The server name must be unique within your AWS account, 75 // within each region. Server names must start with a letter; then letters, 76 // numbers, or hyphens (-) are allowed, up to a maximum of 40 characters. 77 // 78 // This member is required. 79 ServerName *string 80 81 // The service role that the AWS OpsWorks CM service backend uses to work with your 82 // account. Although the AWS OpsWorks management console typically creates the 83 // service role for you, if you are using the AWS CLI or API commands, run the 84 // service-role-creation.yaml AWS CloudFormation template, located at 85 // https://s3.amazonaws.com/opsworks-cm-us-east-1-prod-default-assets/misc/opsworks-cm-roles.yaml. 86 // This template creates a CloudFormation stack that includes the service role and 87 // instance profile that you need. 88 // 89 // This member is required. 90 ServiceRoleArn *string 91 92 // Associate a public IP address with a server that you are launching. Valid values 93 // are true or false. The default value is true. 94 AssociatePublicIpAddress *bool 95 96 // If you specify this field, AWS OpsWorks CM creates the server by using the 97 // backup represented by BackupId. 98 BackupId *string 99 100 // The number of automated backups that you want to keep. Whenever a new backup is 101 // created, AWS OpsWorks CM deletes the oldest backups if this number is exceeded. 102 // The default value is 1. 103 BackupRetentionCount *int32 104 105 // A PEM-formatted HTTPS certificate. The value can be be a single, self-signed 106 // certificate, or a certificate chain. If you specify a custom certificate, you 107 // must also specify values for CustomDomain and CustomPrivateKey. The following 108 // are requirements for the CustomCertificate value: 109 // 110 // * You can provide either a 111 // self-signed, custom certificate, or the full certificate chain. 112 // 113 // * The 114 // certificate must be a valid X509 certificate, or a certificate chain in PEM 115 // format. 116 // 117 // * The certificate must be valid at the time of upload. A certificate 118 // can't be used before its validity period begins (the certificate's NotBefore 119 // date), or after it expires (the certificate's NotAfter date). 120 // 121 // * The 122 // certificate’s common name or subject alternative names (SANs), if present, must 123 // match the value of CustomDomain. 124 // 125 // * The certificate must match the value of 126 // CustomPrivateKey. 127 CustomCertificate *string 128 129 // An optional public endpoint of a server, such as https://aws.my-company.com. To 130 // access the server, create a CNAME DNS record in your preferred DNS service that 131 // points the custom domain to the endpoint that is generated when the server is 132 // created (the value of the CreateServer Endpoint attribute). You cannot access 133 // the server by using the generated Endpoint value if the server is using a custom 134 // domain. If you specify a custom domain, you must also specify values for 135 // CustomCertificate and CustomPrivateKey. 136 CustomDomain *string 137 138 // A private key in PEM format for connecting to the server by using HTTPS. The 139 // private key must not be encrypted; it cannot be protected by a password or 140 // passphrase. If you specify a custom private key, you must also specify values 141 // for CustomDomain and CustomCertificate. 142 CustomPrivateKey *string 143 144 // Enable or disable scheduled backups. Valid values are true or false. The default 145 // value is true. 146 DisableAutomatedBackup *bool 147 148 // Optional engine attributes on a specified server. Attributes accepted in a Chef 149 // createServer request: 150 // 151 // * CHEF_AUTOMATE_PIVOTAL_KEY: A base64-encoded RSA public 152 // key. The corresponding private key is required to access the Chef API. When no 153 // CHEF_AUTOMATE_PIVOTAL_KEY is set, a private key is generated and returned in the 154 // response. 155 // 156 // * CHEF_AUTOMATE_ADMIN_PASSWORD: The password for the administrative 157 // user in the Chef Automate web-based dashboard. The password length is a minimum 158 // of eight characters, and a maximum of 32. The password can contain letters, 159 // numbers, and special characters (!/@#$%^&+=_). The password must contain at 160 // least one lower case letter, one upper case letter, one number, and one special 161 // character. When no CHEF_AUTOMATE_ADMIN_PASSWORD is set, one is generated and 162 // returned in the response. 163 // 164 // Attributes accepted in a Puppet createServer 165 // request: 166 // 167 // * PUPPET_ADMIN_PASSWORD: To work with the Puppet Enterprise console, a 168 // password must use ASCII characters. 169 // 170 // * PUPPET_R10K_REMOTE: The r10k remote is 171 // the URL of your control repository (for example, 172 // ssh://git@your.git-repo.com:user/control-repo.git). Specifying an r10k remote 173 // opens TCP port 8170. 174 // 175 // * PUPPET_R10K_PRIVATE_KEY: If you are using a private Git 176 // repository, add PUPPET_R10K_PRIVATE_KEY to specify a PEM-encoded private SSH 177 // key. 178 EngineAttributes []types.EngineAttribute 179 180 // The engine model of the server. Valid values in this release include Monolithic 181 // for Puppet and Single for Chef. 182 EngineModel *string 183 184 // The major release version of the engine that you want to use. For a Chef server, 185 // the valid value for EngineVersion is currently 2. For a Puppet server, valid 186 // values are 2019 or 2017. 187 EngineVersion *string 188 189 // The Amazon EC2 key pair to set for the instance. This parameter is optional; if 190 // desired, you may specify this parameter to connect to your instances by using 191 // SSH. 192 KeyPair *string 193 194 // The start time for a one-hour period during which AWS OpsWorks CM backs up 195 // application-level data on your server if automated backups are enabled. Valid 196 // values must be specified in one of the following formats: 197 // 198 // * HH:MM for daily 199 // backups 200 // 201 // * DDD:HH:MM for weekly backups 202 // 203 // MM must be specified as 00. The 204 // specified time is in coordinated universal time (UTC). The default value is a 205 // random, daily start time. Example: 08:00, which represents a daily start time of 206 // 08:00 UTC. Example: Mon:08:00, which represents a start time of every Monday at 207 // 08:00 UTC. (8:00 a.m.) 208 PreferredBackupWindow *string 209 210 // The start time for a one-hour period each week during which AWS OpsWorks CM 211 // performs maintenance on the instance. Valid values must be specified in the 212 // following format: DDD:HH:MM. MM must be specified as 00. The specified time is 213 // in coordinated universal time (UTC). The default value is a random one-hour 214 // period on Tuesday, Wednesday, or Friday. See TimeWindowDefinition for more 215 // information. Example: Mon:08:00, which represents a start time of every Monday 216 // at 08:00 UTC. (8:00 a.m.) 217 PreferredMaintenanceWindow *string 218 219 // A list of security group IDs to attach to the Amazon EC2 instance. If you add 220 // this parameter, the specified security groups must be within the VPC that is 221 // specified by SubnetIds. If you do not specify this parameter, AWS OpsWorks CM 222 // creates one new security group that uses TCP ports 22 and 443, open to 0.0.0.0/0 223 // (everyone). 224 SecurityGroupIds []string 225 226 // The IDs of subnets in which to launch the server EC2 instance. Amazon 227 // EC2-Classic customers: This field is required. All servers must run within a 228 // VPC. The VPC must have "Auto Assign Public IP" enabled. EC2-VPC customers: This 229 // field is optional. If you do not specify subnet IDs, your EC2 instances are 230 // created in a default subnet that is selected by Amazon EC2. If you specify 231 // subnet IDs, the VPC must have "Auto Assign Public IP" enabled. For more 232 // information about supported Amazon EC2 platforms, see Supported Platforms 233 // (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-supported-platforms.html). 234 SubnetIds []string 235 236 // A map that contains tag keys and tag values to attach to an AWS OpsWorks for 237 // Chef Automate or AWS OpsWorks for Puppet Enterprise server. 238 // 239 // * The key cannot be 240 // empty. 241 // 242 // * The key can be a maximum of 127 characters, and can contain only 243 // Unicode letters, numbers, or separators, or the following special characters: + 244 // - = . _ : / @ 245 // 246 // * The value can be a maximum 255 characters, and contain only 247 // Unicode letters, numbers, or separators, or the following special characters: + 248 // - = . _ : / @ 249 // 250 // * Leading and trailing white spaces are trimmed from both the key 251 // and value. 252 // 253 // * A maximum of 50 user-applied tags is allowed for any AWS 254 // OpsWorks-CM server. 255 Tags []types.Tag 256 257 noSmithyDocumentSerde 258} 259 260type CreateServerOutput struct { 261 262 // The server that is created by the request. 263 Server *types.Server 264 265 // Metadata pertaining to the operation's result. 266 ResultMetadata middleware.Metadata 267 268 noSmithyDocumentSerde 269} 270 271func (c *Client) addOperationCreateServerMiddlewares(stack *middleware.Stack, options Options) (err error) { 272 err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateServer{}, middleware.After) 273 if err != nil { 274 return err 275 } 276 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateServer{}, middleware.After) 277 if err != nil { 278 return err 279 } 280 if err = addSetLoggerMiddleware(stack, options); err != nil { 281 return err 282 } 283 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 284 return err 285 } 286 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 287 return err 288 } 289 if err = addResolveEndpointMiddleware(stack, options); err != nil { 290 return err 291 } 292 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 293 return err 294 } 295 if err = addRetryMiddlewares(stack, options); err != nil { 296 return err 297 } 298 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 299 return err 300 } 301 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 302 return err 303 } 304 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 305 return err 306 } 307 if err = addClientUserAgent(stack); err != nil { 308 return err 309 } 310 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 311 return err 312 } 313 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 314 return err 315 } 316 if err = addOpCreateServerValidationMiddleware(stack); err != nil { 317 return err 318 } 319 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateServer(options.Region), middleware.Before); err != nil { 320 return err 321 } 322 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 323 return err 324 } 325 if err = addResponseErrorMiddleware(stack); err != nil { 326 return err 327 } 328 if err = addRequestResponseLogging(stack, options); err != nil { 329 return err 330 } 331 return nil 332} 333 334func newServiceMetadataMiddleware_opCreateServer(region string) *awsmiddleware.RegisterServiceMetadata { 335 return &awsmiddleware.RegisterServiceMetadata{ 336 Region: region, 337 ServiceID: ServiceID, 338 SigningName: "opsworks-cm", 339 OperationName: "CreateServer", 340 } 341} 342