{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.EKS.CreateCluster
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates an Amazon EKS control plane.
--
-- The Amazon EKS control plane consists of control plane instances that
-- run the Kubernetes software, such as @etcd@ and the API server. The
-- control plane runs in an account managed by Amazon Web Services, and the
-- Kubernetes API is exposed via the Amazon EKS API server endpoint. Each
-- Amazon EKS cluster control plane is single-tenant and unique and runs on
-- its own set of Amazon EC2 instances.
--
-- The cluster control plane is provisioned across multiple Availability
-- Zones and fronted by an Elastic Load Balancing Network Load Balancer.
-- Amazon EKS also provisions elastic network interfaces in your VPC
-- subnets to provide connectivity from the control plane instances to the
-- nodes (for example, to support @kubectl exec@, @logs@, and @proxy@ data
-- flows).
--
-- Amazon EKS nodes run in your Amazon Web Services account and connect to
-- your cluster\'s control plane via the Kubernetes API server endpoint and
-- a certificate file that is created for your cluster.
--
-- Cluster creation typically takes several minutes. After you create an
-- Amazon EKS cluster, you must configure your Kubernetes tooling to
-- communicate with the API server and launch nodes into your cluster. For
-- more information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/managing-auth.html Managing Cluster Authentication>
-- and
-- <https://docs.aws.amazon.com/eks/latest/userguide/launch-workers.html Launching Amazon EKS nodes>
-- in the /Amazon EKS User Guide/.
module Amazonka.EKS.CreateCluster
  ( -- * Creating a Request
    CreateCluster (..),
    newCreateCluster,

    -- * Request Lenses
    createCluster_kubernetesNetworkConfig,
    createCluster_version,
    createCluster_encryptionConfig,
    createCluster_clientRequestToken,
    createCluster_logging,
    createCluster_tags,
    createCluster_name,
    createCluster_roleArn,
    createCluster_resourcesVpcConfig,

    -- * Destructuring the Response
    CreateClusterResponse (..),
    newCreateClusterResponse,

    -- * Response Lenses
    createClusterResponse_cluster,
    createClusterResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.EKS.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreateCluster' smart constructor.
data CreateCluster = CreateCluster'
  { -- | The Kubernetes network configuration for the cluster.
    CreateCluster -> Maybe KubernetesNetworkConfigRequest
kubernetesNetworkConfig :: Prelude.Maybe KubernetesNetworkConfigRequest,
    -- | The desired Kubernetes version for your cluster. If you don\'t specify a
    -- value here, the latest version available in Amazon EKS is used.
    CreateCluster -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
    -- | The encryption configuration for the cluster.
    CreateCluster -> Maybe [EncryptionConfig]
encryptionConfig :: Prelude.Maybe [EncryptionConfig],
    -- | Unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request.
    CreateCluster -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | Enable or disable exporting the Kubernetes control plane logs for your
    -- cluster to CloudWatch Logs. By default, cluster control plane logs
    -- aren\'t exported to CloudWatch Logs. For more information, see
    -- <https://docs.aws.amazon.com/eks/latest/userguide/control-plane-logs.html Amazon EKS Cluster control plane logs>
    -- in the //Amazon EKS User Guide// .
    --
    -- CloudWatch Logs ingestion, archive storage, and data scanning rates
    -- apply to exported control plane logs. For more information, see
    -- <http://aws.amazon.com/cloudwatch/pricing/ CloudWatch Pricing>.
    CreateCluster -> Maybe Logging
logging :: Prelude.Maybe Logging,
    -- | The metadata to apply to the cluster to assist with categorization and
    -- organization. Each tag consists of a key and an optional value, both of
    -- which you define.
    CreateCluster -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The unique name to give to your cluster.
    CreateCluster -> Text
name :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the IAM role that provides permissions
    -- for the Kubernetes control plane to make calls to Amazon Web Services
    -- API operations on your behalf. For more information, see
    -- <https://docs.aws.amazon.com/eks/latest/userguide/service_IAM_role.html Amazon EKS Service IAM Role>
    -- in the //Amazon EKS User Guide// .
    CreateCluster -> Text
roleArn :: Prelude.Text,
    -- | The VPC configuration used by the cluster control plane. Amazon EKS VPC
    -- resources have specific requirements to work properly with Kubernetes.
    -- For more information, see
    -- <https://docs.aws.amazon.com/eks/latest/userguide/network_reqs.html Cluster VPC Considerations>
    -- and
    -- <https://docs.aws.amazon.com/eks/latest/userguide/sec-group-reqs.html Cluster Security Group Considerations>
    -- in the /Amazon EKS User Guide/. You must specify at least two subnets.
    -- You can specify up to five security groups, but we recommend that you
    -- use a dedicated security group for your cluster control plane.
    CreateCluster -> VpcConfigRequest
resourcesVpcConfig :: VpcConfigRequest
  }
  deriving (CreateCluster -> CreateCluster -> Bool
(CreateCluster -> CreateCluster -> Bool)
-> (CreateCluster -> CreateCluster -> Bool) -> Eq CreateCluster
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCluster -> CreateCluster -> Bool
$c/= :: CreateCluster -> CreateCluster -> Bool
== :: CreateCluster -> CreateCluster -> Bool
$c== :: CreateCluster -> CreateCluster -> Bool
Prelude.Eq, ReadPrec [CreateCluster]
ReadPrec CreateCluster
Int -> ReadS CreateCluster
ReadS [CreateCluster]
(Int -> ReadS CreateCluster)
-> ReadS [CreateCluster]
-> ReadPrec CreateCluster
-> ReadPrec [CreateCluster]
-> Read CreateCluster
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCluster]
$creadListPrec :: ReadPrec [CreateCluster]
readPrec :: ReadPrec CreateCluster
$creadPrec :: ReadPrec CreateCluster
readList :: ReadS [CreateCluster]
$creadList :: ReadS [CreateCluster]
readsPrec :: Int -> ReadS CreateCluster
$creadsPrec :: Int -> ReadS CreateCluster
Prelude.Read, Int -> CreateCluster -> ShowS
[CreateCluster] -> ShowS
CreateCluster -> String
(Int -> CreateCluster -> ShowS)
-> (CreateCluster -> String)
-> ([CreateCluster] -> ShowS)
-> Show CreateCluster
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCluster] -> ShowS
$cshowList :: [CreateCluster] -> ShowS
show :: CreateCluster -> String
$cshow :: CreateCluster -> String
showsPrec :: Int -> CreateCluster -> ShowS
$cshowsPrec :: Int -> CreateCluster -> ShowS
Prelude.Show, (forall x. CreateCluster -> Rep CreateCluster x)
-> (forall x. Rep CreateCluster x -> CreateCluster)
-> Generic CreateCluster
forall x. Rep CreateCluster x -> CreateCluster
forall x. CreateCluster -> Rep CreateCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateCluster x -> CreateCluster
$cfrom :: forall x. CreateCluster -> Rep CreateCluster x
Prelude.Generic)

-- |
-- Create a value of 'CreateCluster' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'kubernetesNetworkConfig', 'createCluster_kubernetesNetworkConfig' - The Kubernetes network configuration for the cluster.
--
-- 'version', 'createCluster_version' - The desired Kubernetes version for your cluster. If you don\'t specify a
-- value here, the latest version available in Amazon EKS is used.
--
-- 'encryptionConfig', 'createCluster_encryptionConfig' - The encryption configuration for the cluster.
--
-- 'clientRequestToken', 'createCluster_clientRequestToken' - Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
--
-- 'logging', 'createCluster_logging' - Enable or disable exporting the Kubernetes control plane logs for your
-- cluster to CloudWatch Logs. By default, cluster control plane logs
-- aren\'t exported to CloudWatch Logs. For more information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/control-plane-logs.html Amazon EKS Cluster control plane logs>
-- in the //Amazon EKS User Guide// .
--
-- CloudWatch Logs ingestion, archive storage, and data scanning rates
-- apply to exported control plane logs. For more information, see
-- <http://aws.amazon.com/cloudwatch/pricing/ CloudWatch Pricing>.
--
-- 'tags', 'createCluster_tags' - The metadata to apply to the cluster to assist with categorization and
-- organization. Each tag consists of a key and an optional value, both of
-- which you define.
--
-- 'name', 'createCluster_name' - The unique name to give to your cluster.
--
-- 'roleArn', 'createCluster_roleArn' - The Amazon Resource Name (ARN) of the IAM role that provides permissions
-- for the Kubernetes control plane to make calls to Amazon Web Services
-- API operations on your behalf. For more information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/service_IAM_role.html Amazon EKS Service IAM Role>
-- in the //Amazon EKS User Guide// .
--
-- 'resourcesVpcConfig', 'createCluster_resourcesVpcConfig' - The VPC configuration used by the cluster control plane. Amazon EKS VPC
-- resources have specific requirements to work properly with Kubernetes.
-- For more information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/network_reqs.html Cluster VPC Considerations>
-- and
-- <https://docs.aws.amazon.com/eks/latest/userguide/sec-group-reqs.html Cluster Security Group Considerations>
-- in the /Amazon EKS User Guide/. You must specify at least two subnets.
-- You can specify up to five security groups, but we recommend that you
-- use a dedicated security group for your cluster control plane.
newCreateCluster ::
  -- | 'name'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  -- | 'resourcesVpcConfig'
  VpcConfigRequest ->
  CreateCluster
newCreateCluster :: Text -> Text -> VpcConfigRequest -> CreateCluster
newCreateCluster
  Text
pName_
  Text
pRoleArn_
  VpcConfigRequest
pResourcesVpcConfig_ =
    CreateCluster' :: Maybe KubernetesNetworkConfigRequest
-> Maybe Text
-> Maybe [EncryptionConfig]
-> Maybe Text
-> Maybe Logging
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> VpcConfigRequest
-> CreateCluster
CreateCluster'
      { $sel:kubernetesNetworkConfig:CreateCluster' :: Maybe KubernetesNetworkConfigRequest
kubernetesNetworkConfig =
          Maybe KubernetesNetworkConfigRequest
forall a. Maybe a
Prelude.Nothing,
        $sel:version:CreateCluster' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:encryptionConfig:CreateCluster' :: Maybe [EncryptionConfig]
encryptionConfig = Maybe [EncryptionConfig]
forall a. Maybe a
Prelude.Nothing,
        $sel:clientRequestToken:CreateCluster' :: Maybe Text
clientRequestToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:logging:CreateCluster' :: Maybe Logging
logging = Maybe Logging
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateCluster' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:name:CreateCluster' :: Text
name = Text
pName_,
        $sel:roleArn:CreateCluster' :: Text
roleArn = Text
pRoleArn_,
        $sel:resourcesVpcConfig:CreateCluster' :: VpcConfigRequest
resourcesVpcConfig = VpcConfigRequest
pResourcesVpcConfig_
      }

-- | The Kubernetes network configuration for the cluster.
createCluster_kubernetesNetworkConfig :: Lens.Lens' CreateCluster (Prelude.Maybe KubernetesNetworkConfigRequest)
createCluster_kubernetesNetworkConfig :: (Maybe KubernetesNetworkConfigRequest
 -> f (Maybe KubernetesNetworkConfigRequest))
-> CreateCluster -> f CreateCluster
createCluster_kubernetesNetworkConfig = (CreateCluster -> Maybe KubernetesNetworkConfigRequest)
-> (CreateCluster
    -> Maybe KubernetesNetworkConfigRequest -> CreateCluster)
-> Lens
     CreateCluster
     CreateCluster
     (Maybe KubernetesNetworkConfigRequest)
     (Maybe KubernetesNetworkConfigRequest)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCluster' {Maybe KubernetesNetworkConfigRequest
kubernetesNetworkConfig :: Maybe KubernetesNetworkConfigRequest
$sel:kubernetesNetworkConfig:CreateCluster' :: CreateCluster -> Maybe KubernetesNetworkConfigRequest
kubernetesNetworkConfig} -> Maybe KubernetesNetworkConfigRequest
kubernetesNetworkConfig) (\s :: CreateCluster
s@CreateCluster' {} Maybe KubernetesNetworkConfigRequest
a -> CreateCluster
s {$sel:kubernetesNetworkConfig:CreateCluster' :: Maybe KubernetesNetworkConfigRequest
kubernetesNetworkConfig = Maybe KubernetesNetworkConfigRequest
a} :: CreateCluster)

-- | The desired Kubernetes version for your cluster. If you don\'t specify a
-- value here, the latest version available in Amazon EKS is used.
createCluster_version :: Lens.Lens' CreateCluster (Prelude.Maybe Prelude.Text)
createCluster_version :: (Maybe Text -> f (Maybe Text)) -> CreateCluster -> f CreateCluster
createCluster_version = (CreateCluster -> Maybe Text)
-> (CreateCluster -> Maybe Text -> CreateCluster)
-> Lens CreateCluster CreateCluster (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCluster' {Maybe Text
version :: Maybe Text
$sel:version:CreateCluster' :: CreateCluster -> Maybe Text
version} -> Maybe Text
version) (\s :: CreateCluster
s@CreateCluster' {} Maybe Text
a -> CreateCluster
s {$sel:version:CreateCluster' :: Maybe Text
version = Maybe Text
a} :: CreateCluster)

-- | The encryption configuration for the cluster.
createCluster_encryptionConfig :: Lens.Lens' CreateCluster (Prelude.Maybe [EncryptionConfig])
createCluster_encryptionConfig :: (Maybe [EncryptionConfig] -> f (Maybe [EncryptionConfig]))
-> CreateCluster -> f CreateCluster
createCluster_encryptionConfig = (CreateCluster -> Maybe [EncryptionConfig])
-> (CreateCluster -> Maybe [EncryptionConfig] -> CreateCluster)
-> Lens
     CreateCluster
     CreateCluster
     (Maybe [EncryptionConfig])
     (Maybe [EncryptionConfig])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCluster' {Maybe [EncryptionConfig]
encryptionConfig :: Maybe [EncryptionConfig]
$sel:encryptionConfig:CreateCluster' :: CreateCluster -> Maybe [EncryptionConfig]
encryptionConfig} -> Maybe [EncryptionConfig]
encryptionConfig) (\s :: CreateCluster
s@CreateCluster' {} Maybe [EncryptionConfig]
a -> CreateCluster
s {$sel:encryptionConfig:CreateCluster' :: Maybe [EncryptionConfig]
encryptionConfig = Maybe [EncryptionConfig]
a} :: CreateCluster) ((Maybe [EncryptionConfig] -> f (Maybe [EncryptionConfig]))
 -> CreateCluster -> f CreateCluster)
-> ((Maybe [EncryptionConfig] -> f (Maybe [EncryptionConfig]))
    -> Maybe [EncryptionConfig] -> f (Maybe [EncryptionConfig]))
-> (Maybe [EncryptionConfig] -> f (Maybe [EncryptionConfig]))
-> CreateCluster
-> f CreateCluster
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [EncryptionConfig]
  [EncryptionConfig]
  [EncryptionConfig]
  [EncryptionConfig]
-> Iso
     (Maybe [EncryptionConfig])
     (Maybe [EncryptionConfig])
     (Maybe [EncryptionConfig])
     (Maybe [EncryptionConfig])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [EncryptionConfig]
  [EncryptionConfig]
  [EncryptionConfig]
  [EncryptionConfig]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
createCluster_clientRequestToken :: Lens.Lens' CreateCluster (Prelude.Maybe Prelude.Text)
createCluster_clientRequestToken :: (Maybe Text -> f (Maybe Text)) -> CreateCluster -> f CreateCluster
createCluster_clientRequestToken = (CreateCluster -> Maybe Text)
-> (CreateCluster -> Maybe Text -> CreateCluster)
-> Lens CreateCluster CreateCluster (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCluster' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:CreateCluster' :: CreateCluster -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: CreateCluster
s@CreateCluster' {} Maybe Text
a -> CreateCluster
s {$sel:clientRequestToken:CreateCluster' :: Maybe Text
clientRequestToken = Maybe Text
a} :: CreateCluster)

-- | Enable or disable exporting the Kubernetes control plane logs for your
-- cluster to CloudWatch Logs. By default, cluster control plane logs
-- aren\'t exported to CloudWatch Logs. For more information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/control-plane-logs.html Amazon EKS Cluster control plane logs>
-- in the //Amazon EKS User Guide// .
--
-- CloudWatch Logs ingestion, archive storage, and data scanning rates
-- apply to exported control plane logs. For more information, see
-- <http://aws.amazon.com/cloudwatch/pricing/ CloudWatch Pricing>.
createCluster_logging :: Lens.Lens' CreateCluster (Prelude.Maybe Logging)
createCluster_logging :: (Maybe Logging -> f (Maybe Logging))
-> CreateCluster -> f CreateCluster
createCluster_logging = (CreateCluster -> Maybe Logging)
-> (CreateCluster -> Maybe Logging -> CreateCluster)
-> Lens CreateCluster CreateCluster (Maybe Logging) (Maybe Logging)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCluster' {Maybe Logging
logging :: Maybe Logging
$sel:logging:CreateCluster' :: CreateCluster -> Maybe Logging
logging} -> Maybe Logging
logging) (\s :: CreateCluster
s@CreateCluster' {} Maybe Logging
a -> CreateCluster
s {$sel:logging:CreateCluster' :: Maybe Logging
logging = Maybe Logging
a} :: CreateCluster)

-- | The metadata to apply to the cluster to assist with categorization and
-- organization. Each tag consists of a key and an optional value, both of
-- which you define.
createCluster_tags :: Lens.Lens' CreateCluster (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createCluster_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateCluster -> f CreateCluster
createCluster_tags = (CreateCluster -> Maybe (HashMap Text Text))
-> (CreateCluster -> Maybe (HashMap Text Text) -> CreateCluster)
-> Lens
     CreateCluster
     CreateCluster
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCluster' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateCluster' :: CreateCluster -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateCluster
s@CreateCluster' {} Maybe (HashMap Text Text)
a -> CreateCluster
s {$sel:tags:CreateCluster' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateCluster) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateCluster -> f CreateCluster)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateCluster
-> f CreateCluster
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The unique name to give to your cluster.
createCluster_name :: Lens.Lens' CreateCluster Prelude.Text
createCluster_name :: (Text -> f Text) -> CreateCluster -> f CreateCluster
createCluster_name = (CreateCluster -> Text)
-> (CreateCluster -> Text -> CreateCluster)
-> Lens CreateCluster CreateCluster Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCluster' {Text
name :: Text
$sel:name:CreateCluster' :: CreateCluster -> Text
name} -> Text
name) (\s :: CreateCluster
s@CreateCluster' {} Text
a -> CreateCluster
s {$sel:name:CreateCluster' :: Text
name = Text
a} :: CreateCluster)

-- | The Amazon Resource Name (ARN) of the IAM role that provides permissions
-- for the Kubernetes control plane to make calls to Amazon Web Services
-- API operations on your behalf. For more information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/service_IAM_role.html Amazon EKS Service IAM Role>
-- in the //Amazon EKS User Guide// .
createCluster_roleArn :: Lens.Lens' CreateCluster Prelude.Text
createCluster_roleArn :: (Text -> f Text) -> CreateCluster -> f CreateCluster
createCluster_roleArn = (CreateCluster -> Text)
-> (CreateCluster -> Text -> CreateCluster)
-> Lens CreateCluster CreateCluster Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCluster' {Text
roleArn :: Text
$sel:roleArn:CreateCluster' :: CreateCluster -> Text
roleArn} -> Text
roleArn) (\s :: CreateCluster
s@CreateCluster' {} Text
a -> CreateCluster
s {$sel:roleArn:CreateCluster' :: Text
roleArn = Text
a} :: CreateCluster)

-- | The VPC configuration used by the cluster control plane. Amazon EKS VPC
-- resources have specific requirements to work properly with Kubernetes.
-- For more information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/network_reqs.html Cluster VPC Considerations>
-- and
-- <https://docs.aws.amazon.com/eks/latest/userguide/sec-group-reqs.html Cluster Security Group Considerations>
-- in the /Amazon EKS User Guide/. You must specify at least two subnets.
-- You can specify up to five security groups, but we recommend that you
-- use a dedicated security group for your cluster control plane.
createCluster_resourcesVpcConfig :: Lens.Lens' CreateCluster VpcConfigRequest
createCluster_resourcesVpcConfig :: (VpcConfigRequest -> f VpcConfigRequest)
-> CreateCluster -> f CreateCluster
createCluster_resourcesVpcConfig = (CreateCluster -> VpcConfigRequest)
-> (CreateCluster -> VpcConfigRequest -> CreateCluster)
-> Lens
     CreateCluster CreateCluster VpcConfigRequest VpcConfigRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCluster' {VpcConfigRequest
resourcesVpcConfig :: VpcConfigRequest
$sel:resourcesVpcConfig:CreateCluster' :: CreateCluster -> VpcConfigRequest
resourcesVpcConfig} -> VpcConfigRequest
resourcesVpcConfig) (\s :: CreateCluster
s@CreateCluster' {} VpcConfigRequest
a -> CreateCluster
s {$sel:resourcesVpcConfig:CreateCluster' :: VpcConfigRequest
resourcesVpcConfig = VpcConfigRequest
a} :: CreateCluster)

instance Core.AWSRequest CreateCluster where
  type
    AWSResponse CreateCluster =
      CreateClusterResponse
  request :: CreateCluster -> Request CreateCluster
request = Service -> CreateCluster -> Request CreateCluster
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateCluster)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateCluster))
-> Logger
-> Service
-> Proxy CreateCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateCluster)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Cluster -> Int -> CreateClusterResponse
CreateClusterResponse'
            (Maybe Cluster -> Int -> CreateClusterResponse)
-> Either String (Maybe Cluster)
-> Either String (Int -> CreateClusterResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Cluster)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"cluster")
            Either String (Int -> CreateClusterResponse)
-> Either String Int -> Either String CreateClusterResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateCluster

instance Prelude.NFData CreateCluster

instance Core.ToHeaders CreateCluster where
  toHeaders :: CreateCluster -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateCluster -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CreateCluster where
  toJSON :: CreateCluster -> Value
toJSON CreateCluster' {Maybe [EncryptionConfig]
Maybe Text
Maybe (HashMap Text Text)
Maybe KubernetesNetworkConfigRequest
Maybe Logging
Text
VpcConfigRequest
resourcesVpcConfig :: VpcConfigRequest
roleArn :: Text
name :: Text
tags :: Maybe (HashMap Text Text)
logging :: Maybe Logging
clientRequestToken :: Maybe Text
encryptionConfig :: Maybe [EncryptionConfig]
version :: Maybe Text
kubernetesNetworkConfig :: Maybe KubernetesNetworkConfigRequest
$sel:resourcesVpcConfig:CreateCluster' :: CreateCluster -> VpcConfigRequest
$sel:roleArn:CreateCluster' :: CreateCluster -> Text
$sel:name:CreateCluster' :: CreateCluster -> Text
$sel:tags:CreateCluster' :: CreateCluster -> Maybe (HashMap Text Text)
$sel:logging:CreateCluster' :: CreateCluster -> Maybe Logging
$sel:clientRequestToken:CreateCluster' :: CreateCluster -> Maybe Text
$sel:encryptionConfig:CreateCluster' :: CreateCluster -> Maybe [EncryptionConfig]
$sel:version:CreateCluster' :: CreateCluster -> Maybe Text
$sel:kubernetesNetworkConfig:CreateCluster' :: CreateCluster -> Maybe KubernetesNetworkConfigRequest
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"kubernetesNetworkConfig" Text -> KubernetesNetworkConfigRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (KubernetesNetworkConfigRequest -> Pair)
-> Maybe KubernetesNetworkConfigRequest -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe KubernetesNetworkConfigRequest
kubernetesNetworkConfig,
            (Text
"version" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
version,
            (Text
"encryptionConfig" Text -> [EncryptionConfig] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([EncryptionConfig] -> Pair)
-> Maybe [EncryptionConfig] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [EncryptionConfig]
encryptionConfig,
            (Text
"clientRequestToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientRequestToken,
            (Text
"logging" Text -> Logging -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Logging -> Pair) -> Maybe Logging -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Logging
logging,
            (Text
"tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"roleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"resourcesVpcConfig" Text -> VpcConfigRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= VpcConfigRequest
resourcesVpcConfig)
          ]
      )

instance Core.ToPath CreateCluster where
  toPath :: CreateCluster -> ByteString
toPath = ByteString -> CreateCluster -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/clusters"

instance Core.ToQuery CreateCluster where
  toQuery :: CreateCluster -> QueryString
toQuery = QueryString -> CreateCluster -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreateClusterResponse' smart constructor.
data CreateClusterResponse = CreateClusterResponse'
  { -- | The full description of your new cluster.
    CreateClusterResponse -> Maybe Cluster
cluster :: Prelude.Maybe Cluster,
    -- | The response's http status code.
    CreateClusterResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateClusterResponse -> CreateClusterResponse -> Bool
(CreateClusterResponse -> CreateClusterResponse -> Bool)
-> (CreateClusterResponse -> CreateClusterResponse -> Bool)
-> Eq CreateClusterResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateClusterResponse -> CreateClusterResponse -> Bool
$c/= :: CreateClusterResponse -> CreateClusterResponse -> Bool
== :: CreateClusterResponse -> CreateClusterResponse -> Bool
$c== :: CreateClusterResponse -> CreateClusterResponse -> Bool
Prelude.Eq, ReadPrec [CreateClusterResponse]
ReadPrec CreateClusterResponse
Int -> ReadS CreateClusterResponse
ReadS [CreateClusterResponse]
(Int -> ReadS CreateClusterResponse)
-> ReadS [CreateClusterResponse]
-> ReadPrec CreateClusterResponse
-> ReadPrec [CreateClusterResponse]
-> Read CreateClusterResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateClusterResponse]
$creadListPrec :: ReadPrec [CreateClusterResponse]
readPrec :: ReadPrec CreateClusterResponse
$creadPrec :: ReadPrec CreateClusterResponse
readList :: ReadS [CreateClusterResponse]
$creadList :: ReadS [CreateClusterResponse]
readsPrec :: Int -> ReadS CreateClusterResponse
$creadsPrec :: Int -> ReadS CreateClusterResponse
Prelude.Read, Int -> CreateClusterResponse -> ShowS
[CreateClusterResponse] -> ShowS
CreateClusterResponse -> String
(Int -> CreateClusterResponse -> ShowS)
-> (CreateClusterResponse -> String)
-> ([CreateClusterResponse] -> ShowS)
-> Show CreateClusterResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateClusterResponse] -> ShowS
$cshowList :: [CreateClusterResponse] -> ShowS
show :: CreateClusterResponse -> String
$cshow :: CreateClusterResponse -> String
showsPrec :: Int -> CreateClusterResponse -> ShowS
$cshowsPrec :: Int -> CreateClusterResponse -> ShowS
Prelude.Show, (forall x. CreateClusterResponse -> Rep CreateClusterResponse x)
-> (forall x. Rep CreateClusterResponse x -> CreateClusterResponse)
-> Generic CreateClusterResponse
forall x. Rep CreateClusterResponse x -> CreateClusterResponse
forall x. CreateClusterResponse -> Rep CreateClusterResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateClusterResponse x -> CreateClusterResponse
$cfrom :: forall x. CreateClusterResponse -> Rep CreateClusterResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateClusterResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'cluster', 'createClusterResponse_cluster' - The full description of your new cluster.
--
-- 'httpStatus', 'createClusterResponse_httpStatus' - The response's http status code.
newCreateClusterResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateClusterResponse
newCreateClusterResponse :: Int -> CreateClusterResponse
newCreateClusterResponse Int
pHttpStatus_ =
  CreateClusterResponse' :: Maybe Cluster -> Int -> CreateClusterResponse
CreateClusterResponse'
    { $sel:cluster:CreateClusterResponse' :: Maybe Cluster
cluster = Maybe Cluster
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateClusterResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The full description of your new cluster.
createClusterResponse_cluster :: Lens.Lens' CreateClusterResponse (Prelude.Maybe Cluster)
createClusterResponse_cluster :: (Maybe Cluster -> f (Maybe Cluster))
-> CreateClusterResponse -> f CreateClusterResponse
createClusterResponse_cluster = (CreateClusterResponse -> Maybe Cluster)
-> (CreateClusterResponse
    -> Maybe Cluster -> CreateClusterResponse)
-> Lens
     CreateClusterResponse
     CreateClusterResponse
     (Maybe Cluster)
     (Maybe Cluster)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateClusterResponse' {Maybe Cluster
cluster :: Maybe Cluster
$sel:cluster:CreateClusterResponse' :: CreateClusterResponse -> Maybe Cluster
cluster} -> Maybe Cluster
cluster) (\s :: CreateClusterResponse
s@CreateClusterResponse' {} Maybe Cluster
a -> CreateClusterResponse
s {$sel:cluster:CreateClusterResponse' :: Maybe Cluster
cluster = Maybe Cluster
a} :: CreateClusterResponse)

-- | The response's http status code.
createClusterResponse_httpStatus :: Lens.Lens' CreateClusterResponse Prelude.Int
createClusterResponse_httpStatus :: (Int -> f Int) -> CreateClusterResponse -> f CreateClusterResponse
createClusterResponse_httpStatus = (CreateClusterResponse -> Int)
-> (CreateClusterResponse -> Int -> CreateClusterResponse)
-> Lens CreateClusterResponse CreateClusterResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateClusterResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateClusterResponse' :: CreateClusterResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateClusterResponse
s@CreateClusterResponse' {} Int
a -> CreateClusterResponse
s {$sel:httpStatus:CreateClusterResponse' :: Int
httpStatus = Int
a} :: CreateClusterResponse)

instance Prelude.NFData CreateClusterResponse