Skip to content

Commit 527c6f6

Browse files
committed
chore: create infra for svc search 3
1 parent 84fd610 commit 527c6f6

File tree

3 files changed

+121
-0
lines changed

3 files changed

+121
-0
lines changed

SAMtemplates/functions/main.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Globals:
2222
SpinePartyKeyARN: !ImportValue account-resources:SpinePartyKey
2323
SpineCAChainARN: !ImportValue account-resources:SpineCAChain
2424
ServiceSearchApiKeyARN: !ImportValue account-resources:ServiceSearchApiKey
25+
ServiceSearch3ApiKeyARN: !Ref ServiceSearch3ApiKeyARN
2526
Layers:
2627
- !Sub arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension:52
2728

@@ -30,6 +31,10 @@ Parameters:
3031
Type: String
3132
Default: none
3233

34+
ServiceSearch3ApiKeyARN:
35+
Type: String
36+
Description: ARN of the Service Search API v3 Key Secret
37+
3338
Env:
3439
Type: String
3540
Default: dev
@@ -68,6 +73,14 @@ Parameters:
6873
SSMParameterPolicy:
6974
Type: String
7075

76+
SecretsPolicy:
77+
Type: String
78+
Description: ARN of the policy to read secrets
79+
80+
KMSPolicy:
81+
Type: String
82+
Description: ARN of the policy to use KMS key
83+
7184
Resources:
7285
GetSecretsLayer:
7386
Type: AWS::Serverless::LayerVersion
@@ -121,6 +134,8 @@ Resources:
121134
- ","
122135
- - !ImportValue account-resources:LambdaAccessSecretsPolicy
123136
- !Ref SSMParameterPolicy
137+
- !Ref SecretsPolicy
138+
- !Ref KMSPolicy
124139
LogRetentionInDays: !Ref LogRetentionInDays
125140
CloudWatchKMSKeyId: !ImportValue account-resources:CloudwatchLogsKmsKeyArn
126141
EnableSplunk: !Ref EnableSplunk

SAMtemplates/main_template.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,16 @@ Resources:
168168
CommitId: !Ref CommitId
169169
ToggleGetStatusUpdates: !Ref ToggleGetStatusUpdates
170170
SSMParameterPolicy: !GetAtt Parameters.Outputs.GetPfPParameterPolicy
171+
ServiceSearch3ApiKeyARN: !GetAtt Secrets.Outputs.PfPServiceSearchApiKeySecret
172+
SecretsPolicy: !GetAtt Secrets.Outputs.GetPfPSecretPolicy
173+
KMSPolicy: !GetAtt Secrets.Outputs.UsePfPSecretsKMSKeyPolicyArn
174+
175+
Secrets:
176+
Type: AWS::Serverless::Application
177+
Properties:
178+
Location: secrets/main.yaml
179+
Parameters:
180+
StackName: !Ref AWS::StackName
171181

172182
StateMachines:
173183
Type: AWS::Serverless::Application

SAMtemplates/secrets/main.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
AWSTemplateFormatVersion: "2010-09-09"
2+
3+
Parameters:
4+
StackName:
5+
Type: String
6+
Default: none
7+
8+
Resources:
9+
PfPSecretsKMSKey:
10+
Type: AWS::KMS::Key
11+
Properties:
12+
EnableKeyRotation: true
13+
KeyPolicy:
14+
Version: 2012-10-17
15+
Id: PfPSecretsKeyPolicy
16+
Statement:
17+
- Sid: EnableIAMUserPermissions
18+
Effect: Allow
19+
Principal:
20+
AWS: !Sub "arn:aws:iam::${AWS::AccountId}:root"
21+
Action: kms:*
22+
Resource: "*"
23+
- Sid: Enable read only decrypt
24+
Effect: Allow
25+
Principal:
26+
AWS: "*"
27+
Action:
28+
- kms:DescribeKey
29+
- kms:Decrypt
30+
Resource: "*"
31+
Condition:
32+
ArnLike:
33+
aws:PrincipalArn: !Sub "arn:aws:iam::${AWS::AccountId}:role/aws-reserved/sso.amazonaws.com/${AWS::Region}/AWSReservedSSO_ReadOnly*"
34+
35+
PfPSecretsKMSKeyAlias:
36+
Type: AWS::KMS::Alias
37+
Properties:
38+
AliasName: !Sub alias/${StackName}-PfPSecretsKMSKey
39+
TargetKeyId: !Ref PfPSecretsKMSKey
40+
41+
UsePfPSecretsKMSKeyPolicy:
42+
Type: AWS::IAM::ManagedPolicy
43+
Properties:
44+
ManagedPolicyName: !Sub ${StackName}-UsePfPSecretsKMSKey
45+
PolicyDocument:
46+
Version: "2012-10-17"
47+
Statement:
48+
- Sid: AllowKmsForSecretsEncryption
49+
Effect: Allow
50+
Action:
51+
- kms:DescribeKey
52+
- kms:GenerateDataKey*
53+
- kms:Encrypt
54+
- kms:ReEncrypt*
55+
- kms:Decrypt
56+
Resource: !GetAtt PfPSecretsKMSKey.Arn
57+
58+
PfPServiceSearchApiKeySecret:
59+
Type: AWS::SecretsManager::Secret
60+
Properties:
61+
Name: !Sub ${StackName}-PfP-ServiceSearch-API-Key
62+
Description: API Key for Service Search
63+
KmsKeyId: !Ref PfPSecretsKMSKey
64+
65+
GetPfPSecretPolicy:
66+
Type: AWS::IAM::ManagedPolicy
67+
Properties:
68+
Description: "Allows reading PfP secret parameters"
69+
PolicyDocument:
70+
Version: 2012-10-17
71+
Statement:
72+
- Effect: Allow
73+
Action:
74+
- secretsmanager:GetSecretValue
75+
- secretsmanager:DescribeSecret
76+
Resource:
77+
- !Ref PfPServiceSearchApiKeySecret
78+
79+
Outputs:
80+
PfPServiceSearchApiKeySecret:
81+
Description: The name of the PfP Service Search API Key secret
82+
Value: !Ref PfPServiceSearchApiKeySecret
83+
Export:
84+
Name: !Sub ${StackName}-PfP-ServiceSearch-API-Key
85+
86+
GetPfPSecretPolicy:
87+
Description: ARN of policy granting permission to read secrets
88+
Value: !Ref GetPfPSecretPolicy
89+
Export:
90+
Name: !Sub ${StackName}-GetPfPSecretPolicy
91+
92+
UsePfPSecretsKMSKeyPolicyArn:
93+
Description: ARN of managed policy granting PfP secrets KMS usage
94+
Value: !Ref UsePfPSecretsKMSKeyPolicy
95+
Export:
96+
Name: !Sub ${StackName}-UsePfPSecretsKMSKeyPolicyArn

0 commit comments

Comments
 (0)