# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy of this # software and associated documentation files (the "Software"), to deal in the Software # without restriction, including without limitation the rights to use, copy, modify, # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so. # # THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. AWSTemplateFormatVersion: 2010-09-09 Description: | This template creates the roles utilized for setting up the Docker Image Builder Pipeline. Resources: # Service Role for AWS CodePipeline LambdaExecutionRole: Type: AWS::IAM::Role Properties: RoleName: !Sub "${AWS::StackName}-lambda-execution-role" ManagedPolicyArns: - arn:aws:iam::aws:policy/AmazonEC2FullAccess - arn:aws:iam::aws:policy/AWSCloudFormationFullAccess AssumeRolePolicyDocument: Version: '2012-10-17' Statement: Action: - 'sts:AssumeRole' Effect: Allow Principal: Service: - lambda.amazonaws.com - eks.amazonaws.com Path: / # IAM Policies for CodePipeline and CodeBuild EksAllAccessPolicy: Type: AWS::IAM::ManagedPolicy Properties: ManagedPolicyName: !Sub "${AWS::StackName}-lambda-execution-policy" PolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Action: - 'eks:UpdateClusterVersion' - 'eks:ListNodegroups' - 'eks:UpdateAddon' - 'eks:ListAddons' - 'eks:UpdateClusterConfig' - 'eks:CreateNodegroup' - 'eks:DescribeAddon' - 'eks:UpdateNodegroupVersion' - 'eks:ListUpdates' - 'eks:DescribeUpdate' - 'eks:AccessKubernetesApi' - 'eks:CreateAddon' - 'eks:UpdateNodegroupConfig' - 'eks:DescribeCluster' - 'eks:ListIdentityProviderConfigs' Resource: - !Sub 'arn:aws:eks:*:${AWS::AccountId}:addon/*/*/*' - !Sub 'arn:aws:eks:*:${AWS::AccountId}:nodegroup/*/*/*' - !Sub 'arn:aws:eks:*:${AWS::AccountId}:cluster/*' - Effect: "Allow" Action: - 'logs:CreateLogStream' - 'logs:DescribeLogGroups' - 'logs:DescribeLogStreams' - 'logs:CreateLogGroup' - 'logs:DeleteLogStream' - 'logs:PutLogEvents' Resource: - !Sub 'arn:aws:logs:*:${AWS::AccountId}:log-group:*' - !Sub 'arn:aws:logs:*:${AWS::AccountId}:log-group:*:log-stream:*' - Effect: "Allow" Action: - 'eks:ListClusters' - 'eks:CreateCluster' Resource: - '*' Roles: - !Ref LambdaExecutionRole Outputs: LambdaRole: Value: !GetAtt LambdaExecutionRole.Arn Export: Name: !Sub "${AWS::StackName}-lambda-execution-role-arn"