{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.RemoteAccessConfig
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.EKS.Types.RemoteAccessConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | An object representing the remote access configuration for the managed
-- node group.
--
-- /See:/ 'newRemoteAccessConfig' smart constructor.
data RemoteAccessConfig = RemoteAccessConfig'
  { -- | The Amazon EC2 SSH key name that provides access for SSH communication
    -- with the nodes in the managed node group. For more information, see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html Amazon EC2 key pairs and Linux instances>
    -- in the /Amazon Elastic Compute Cloud User Guide for Linux Instances/.
    -- For Windows, an Amazon EC2 SSH key is used to obtain the RDP password.
    -- For more information, see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-key-pairs.html Amazon EC2 key pairs and Windows instances>
    -- in the /Amazon Elastic Compute Cloud User Guide for Windows Instances/.
    RemoteAccessConfig -> Maybe Text
ec2SshKey :: Prelude.Maybe Prelude.Text,
    -- | The security group IDs that are allowed SSH access (port 22) to the
    -- nodes. For Windows, the port is 3389. If you specify an Amazon EC2 SSH
    -- key but don\'t specify a source security group when you create a managed
    -- node group, then the port on the nodes is opened to the internet
    -- (@0.0.0.0\/0@). For more information, see
    -- <https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html Security Groups for Your VPC>
    -- in the /Amazon Virtual Private Cloud User Guide/.
    RemoteAccessConfig -> Maybe [Text]
sourceSecurityGroups :: Prelude.Maybe [Prelude.Text]
  }
  deriving (RemoteAccessConfig -> RemoteAccessConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoteAccessConfig -> RemoteAccessConfig -> Bool
$c/= :: RemoteAccessConfig -> RemoteAccessConfig -> Bool
== :: RemoteAccessConfig -> RemoteAccessConfig -> Bool
$c== :: RemoteAccessConfig -> RemoteAccessConfig -> Bool
Prelude.Eq, ReadPrec [RemoteAccessConfig]
ReadPrec RemoteAccessConfig
Int -> ReadS RemoteAccessConfig
ReadS [RemoteAccessConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoteAccessConfig]
$creadListPrec :: ReadPrec [RemoteAccessConfig]
readPrec :: ReadPrec RemoteAccessConfig
$creadPrec :: ReadPrec RemoteAccessConfig
readList :: ReadS [RemoteAccessConfig]
$creadList :: ReadS [RemoteAccessConfig]
readsPrec :: Int -> ReadS RemoteAccessConfig
$creadsPrec :: Int -> ReadS RemoteAccessConfig
Prelude.Read, Int -> RemoteAccessConfig -> ShowS
[RemoteAccessConfig] -> ShowS
RemoteAccessConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoteAccessConfig] -> ShowS
$cshowList :: [RemoteAccessConfig] -> ShowS
show :: RemoteAccessConfig -> String
$cshow :: RemoteAccessConfig -> String
showsPrec :: Int -> RemoteAccessConfig -> ShowS
$cshowsPrec :: Int -> RemoteAccessConfig -> ShowS
Prelude.Show, forall x. Rep RemoteAccessConfig x -> RemoteAccessConfig
forall x. RemoteAccessConfig -> Rep RemoteAccessConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RemoteAccessConfig x -> RemoteAccessConfig
$cfrom :: forall x. RemoteAccessConfig -> Rep RemoteAccessConfig x
Prelude.Generic)

-- |
-- Create a value of 'RemoteAccessConfig' 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:
--
-- 'ec2SshKey', 'remoteAccessConfig_ec2SshKey' - The Amazon EC2 SSH key name that provides access for SSH communication
-- with the nodes in the managed node group. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html Amazon EC2 key pairs and Linux instances>
-- in the /Amazon Elastic Compute Cloud User Guide for Linux Instances/.
-- For Windows, an Amazon EC2 SSH key is used to obtain the RDP password.
-- For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-key-pairs.html Amazon EC2 key pairs and Windows instances>
-- in the /Amazon Elastic Compute Cloud User Guide for Windows Instances/.
--
-- 'sourceSecurityGroups', 'remoteAccessConfig_sourceSecurityGroups' - The security group IDs that are allowed SSH access (port 22) to the
-- nodes. For Windows, the port is 3389. If you specify an Amazon EC2 SSH
-- key but don\'t specify a source security group when you create a managed
-- node group, then the port on the nodes is opened to the internet
-- (@0.0.0.0\/0@). For more information, see
-- <https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html Security Groups for Your VPC>
-- in the /Amazon Virtual Private Cloud User Guide/.
newRemoteAccessConfig ::
  RemoteAccessConfig
newRemoteAccessConfig :: RemoteAccessConfig
newRemoteAccessConfig =
  RemoteAccessConfig'
    { $sel:ec2SshKey:RemoteAccessConfig' :: Maybe Text
ec2SshKey = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceSecurityGroups:RemoteAccessConfig' :: Maybe [Text]
sourceSecurityGroups = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon EC2 SSH key name that provides access for SSH communication
-- with the nodes in the managed node group. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html Amazon EC2 key pairs and Linux instances>
-- in the /Amazon Elastic Compute Cloud User Guide for Linux Instances/.
-- For Windows, an Amazon EC2 SSH key is used to obtain the RDP password.
-- For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-key-pairs.html Amazon EC2 key pairs and Windows instances>
-- in the /Amazon Elastic Compute Cloud User Guide for Windows Instances/.
remoteAccessConfig_ec2SshKey :: Lens.Lens' RemoteAccessConfig (Prelude.Maybe Prelude.Text)
remoteAccessConfig_ec2SshKey :: Lens' RemoteAccessConfig (Maybe Text)
remoteAccessConfig_ec2SshKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoteAccessConfig' {Maybe Text
ec2SshKey :: Maybe Text
$sel:ec2SshKey:RemoteAccessConfig' :: RemoteAccessConfig -> Maybe Text
ec2SshKey} -> Maybe Text
ec2SshKey) (\s :: RemoteAccessConfig
s@RemoteAccessConfig' {} Maybe Text
a -> RemoteAccessConfig
s {$sel:ec2SshKey:RemoteAccessConfig' :: Maybe Text
ec2SshKey = Maybe Text
a} :: RemoteAccessConfig)

-- | The security group IDs that are allowed SSH access (port 22) to the
-- nodes. For Windows, the port is 3389. If you specify an Amazon EC2 SSH
-- key but don\'t specify a source security group when you create a managed
-- node group, then the port on the nodes is opened to the internet
-- (@0.0.0.0\/0@). For more information, see
-- <https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html Security Groups for Your VPC>
-- in the /Amazon Virtual Private Cloud User Guide/.
remoteAccessConfig_sourceSecurityGroups :: Lens.Lens' RemoteAccessConfig (Prelude.Maybe [Prelude.Text])
remoteAccessConfig_sourceSecurityGroups :: Lens' RemoteAccessConfig (Maybe [Text])
remoteAccessConfig_sourceSecurityGroups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoteAccessConfig' {Maybe [Text]
sourceSecurityGroups :: Maybe [Text]
$sel:sourceSecurityGroups:RemoteAccessConfig' :: RemoteAccessConfig -> Maybe [Text]
sourceSecurityGroups} -> Maybe [Text]
sourceSecurityGroups) (\s :: RemoteAccessConfig
s@RemoteAccessConfig' {} Maybe [Text]
a -> RemoteAccessConfig
s {$sel:sourceSecurityGroups:RemoteAccessConfig' :: Maybe [Text]
sourceSecurityGroups = Maybe [Text]
a} :: RemoteAccessConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON RemoteAccessConfig where
  parseJSON :: Value -> Parser RemoteAccessConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RemoteAccessConfig"
      ( \Object
x ->
          Maybe Text -> Maybe [Text] -> RemoteAccessConfig
RemoteAccessConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ec2SshKey")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"sourceSecurityGroups"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable RemoteAccessConfig where
  hashWithSalt :: Int -> RemoteAccessConfig -> Int
hashWithSalt Int
_salt RemoteAccessConfig' {Maybe [Text]
Maybe Text
sourceSecurityGroups :: Maybe [Text]
ec2SshKey :: Maybe Text
$sel:sourceSecurityGroups:RemoteAccessConfig' :: RemoteAccessConfig -> Maybe [Text]
$sel:ec2SshKey:RemoteAccessConfig' :: RemoteAccessConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ec2SshKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
sourceSecurityGroups

instance Prelude.NFData RemoteAccessConfig where
  rnf :: RemoteAccessConfig -> ()
rnf RemoteAccessConfig' {Maybe [Text]
Maybe Text
sourceSecurityGroups :: Maybe [Text]
ec2SshKey :: Maybe Text
$sel:sourceSecurityGroups:RemoteAccessConfig' :: RemoteAccessConfig -> Maybe [Text]
$sel:ec2SshKey:RemoteAccessConfig' :: RemoteAccessConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ec2SshKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
sourceSecurityGroups

instance Data.ToJSON RemoteAccessConfig where
  toJSON :: RemoteAccessConfig -> Value
toJSON RemoteAccessConfig' {Maybe [Text]
Maybe Text
sourceSecurityGroups :: Maybe [Text]
ec2SshKey :: Maybe Text
$sel:sourceSecurityGroups:RemoteAccessConfig' :: RemoteAccessConfig -> Maybe [Text]
$sel:ec2SshKey:RemoteAccessConfig' :: RemoteAccessConfig -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ec2SshKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
ec2SshKey,
            (Key
"sourceSecurityGroups" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
sourceSecurityGroups
          ]
      )