{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} -- Module : Network.AWS.IAM.AttachRolePolicy -- Copyright : (c) 2013-2014 Brendan Hay -- License : This Source Code Form is subject to the terms of -- the Mozilla Public License, v. 2.0. -- A copy of the MPL can be found in the LICENSE file or -- you can obtain it at http://mozilla.org/MPL/2.0/. -- Maintainer : Brendan Hay -- Stability : experimental -- Portability : non-portable (GHC extensions) -- -- Derived from AWS service descriptions, licensed under Apache 2.0. -- | Attaches the specified managed policy to the specified role. -- -- When you attach a managed policy to a role, the managed policy is used as -- the role's access (permissions) policy. You cannot use a managed policy as -- the role's trust policy. The role's trust policy is created at the same time -- as the role, using 'CreateRole'. You can update a role's trust policy using 'UpdateAssumeRolePolicy'. -- -- Use this API to attach a managed policy to a role. To embed an inline policy -- in a role, use 'PutRolePolicy'. For more information about policies, refer to in the /Using IAM/ guide. -- -- module Network.AWS.IAM.AttachRolePolicy ( -- * Request AttachRolePolicy -- ** Request constructor , attachRolePolicy -- ** Request lenses , arpPolicyArn , arpRoleName -- * Response , AttachRolePolicyResponse -- ** Response constructor , attachRolePolicyResponse ) where import Network.AWS.Prelude import Network.AWS.Request.Query import Network.AWS.IAM.Types import qualified GHC.Exts data AttachRolePolicy = AttachRolePolicy { _arpPolicyArn :: Text , _arpRoleName :: Text } deriving (Eq, Ord, Read, Show) -- | 'AttachRolePolicy' constructor. -- -- The fields accessible through corresponding lenses are: -- -- * 'arpPolicyArn' @::@ 'Text' -- -- * 'arpRoleName' @::@ 'Text' -- attachRolePolicy :: Text -- ^ 'arpRoleName' -> Text -- ^ 'arpPolicyArn' -> AttachRolePolicy attachRolePolicy p1 p2 = AttachRolePolicy { _arpRoleName = p1 , _arpPolicyArn = p2 } arpPolicyArn :: Lens' AttachRolePolicy Text arpPolicyArn = lens _arpPolicyArn (\s a -> s { _arpPolicyArn = a }) -- | The name (friendly name, not ARN) of the role to attach the policy to. arpRoleName :: Lens' AttachRolePolicy Text arpRoleName = lens _arpRoleName (\s a -> s { _arpRoleName = a }) data AttachRolePolicyResponse = AttachRolePolicyResponse deriving (Eq, Ord, Read, Show, Generic) -- | 'AttachRolePolicyResponse' constructor. attachRolePolicyResponse :: AttachRolePolicyResponse attachRolePolicyResponse = AttachRolePolicyResponse instance ToPath AttachRolePolicy where toPath = const "/" instance ToQuery AttachRolePolicy where toQuery AttachRolePolicy{..} = mconcat [ "PolicyArn" =? _arpPolicyArn , "RoleName" =? _arpRoleName ] instance ToHeaders AttachRolePolicy instance AWSRequest AttachRolePolicy where type Sv AttachRolePolicy = IAM type Rs AttachRolePolicy = AttachRolePolicyResponse request = post "AttachRolePolicy" response = nullResponse AttachRolePolicyResponse