-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodule.yml
More file actions
61 lines (61 loc) · 2.04 KB
/
module.yml
File metadata and controls
61 lines (61 loc) · 2.04 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
---
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
AWSTemplateFormatVersion: '2010-09-09'
Description: 'cfn-modules: AWS Secrets Manager secret'
# cfn-modules:implements(ExposeArn)
Parameters:
KmsKeyModule:
Description: 'Optional but recommended stack name of kms-key module.'
Type: String
Default: ''
Name:
Description: 'Optional name of the secret.'
Type: String
Default: ''
Description:
Description: 'Optional description of the secret.'
Type: String
Default: ''
CharactersToExclude:
Description: 'Optional characters not to be used when generating the initial value.'
Type: String
Default: '"@/\'
PasswordLength:
Description: 'Optional length of the generated password'
Type: Number
Default: 30
Conditions:
HasKmsKeyModule: !Not [!Equals [!Ref KmsKeyModule, '']]
HasName: !Not [!Equals [!Ref Name, '']]
HasDescription: !Not [!Equals [!Ref Description, '']]
Resources:
Secret:
Type: 'AWS::SecretsManager::Secret'
Properties:
KmsKeyId: !If [HasKmsKeyModule, {'Fn::ImportValue': !Sub '${KmsKeyModule}-Arn'}, !Ref 'AWS::NoValue']
Name: !If [HasName, !Ref 'Name', !Ref 'AWS::NoValue']
Description: !If [HasDescription, !Ref 'Description', !Ref 'AWS::NoValue']
GenerateSecretString:
PasswordLength: !Ref PasswordLength
ExcludeCharacters: !Ref 'CharactersToExclude'
Outputs:
ModuleId:
Value: 'secret'
ModuleVersion:
Value: '1.3.0'
StackName:
Value: !Ref 'AWS::StackName'
Arn:
Value: !Ref Secret
Export:
Name: !Sub '${AWS::StackName}-Arn'