-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-4-cloudformation.yml
49 lines (45 loc) · 1.32 KB
/
example-4-cloudformation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
AWSTemplateFormatVersion: '2010-09-09'
Description: IAM role for accessing SSM parameters
Parameters:
Name:
Description: Name of user
Type: String
KmsKeyId:
Type: "String"
EnvironmentName:
Type: "String"
ProjectName:
Type: "String"
Resources:
SsmParameterUser:
Type: "AWS::IAM::User"
Properties:
Policies:
- PolicyName: "secrets-management"
PolicyDocument:
Version: "2012-10-17"
Id: "AllowAccessToParameters"
Statement:
- Sid: "AllowAccessToGetParametersByPath"
Effect: "Allow"
Action: "ssm:GetParametersByPath"
Resource:
- !Sub "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/${ProjectName}/${EnvironmentName}"
- Sid: "AllowAccessToDecryptParameters"
Effect: "Allow"
Action: "kms:Decrypt"
Resource:
- !Sub "arn:aws:kms:${AWS::Region}:*:key/${KmsKeyId}"
UserName: !Join [ "-", [ !Ref Name, "ssm" ] ]
SsmParameterUserKey:
DependsOn: SsmParameterUser
Type: "AWS::IAM::AccessKey"
Properties:
Status: Active
UserName: !Ref SsmParameterUser
Outputs:
AccessKey:
Value:
Ref: SsmParameterUserKey
SecretKey:
Value: !GetAtt SsmParameterUserKey.SecretAccessKey