Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

Commit 0c4d63f

Browse files
authored
update appregistry config to support multiple deployments and allow s3 to name bucket (#180)
1 parent 0fcd513 commit 0c4d63f

File tree

2 files changed

+22
-67
lines changed

2 files changed

+22
-67
lines changed

deployment/efs-file-manager-web.yaml

Lines changed: 11 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -32,70 +32,23 @@ Mappings:
3232
WebsitePrefix: "simple-file-manager-for-amazon-efs/%%VERSION%%/website"
3333

3434
Resources:
35-
WebsiteBucketNameFunction:
36-
Type: AWS::Lambda::Function
35+
EFSFileSimpleLoggingBucket:
36+
Type: 'AWS::S3::Bucket'
3737
Metadata:
38-
cfn_nag:
39-
rules_to_suppress:
40-
- id: W89
41-
reason: "Custom resource deployed in default VPC"
42-
- id: W92
43-
reason: "ReservedConcurrentExecutions not needed since this function runs once when CloudFormation deploys"
44-
Properties:
45-
Code:
46-
ZipFile: |
47-
import string
48-
import random
49-
import cfnresponse
50-
def handler(event, context):
51-
stack_name = event['StackId'].split('/')[1].split('-Uuid')[0]
52-
response_data = {'Data': stack_name.lower() + '-website'}
53-
cfnresponse.send(event, context, cfnresponse.SUCCESS, response_data, "CustomResourcePhysicalID")
54-
Handler: index.handler
55-
Runtime: python3.8
56-
Role: !GetAtt WebsiteBucketNameExecutionRole.Arn
57-
WebsiteBucketNameFunctionPermissions:
58-
Type: AWS::Lambda::Permission
59-
Properties:
60-
Action: 'lambda:InvokeFunction'
61-
FunctionName: !GetAtt WebsiteBucketNameFunction.Arn
62-
Principal: 'cloudformation.amazonaws.com'
63-
WebsiteBucketNameExecutionRole:
64-
Type: AWS::IAM::Role
65-
Properties:
66-
AssumeRolePolicyDocument:
67-
Version: 2012-10-17
68-
Statement:
69-
- Effect: Allow
70-
Principal:
71-
Service:
72-
- lambda.amazonaws.com
73-
Action:
74-
- sts:AssumeRole
75-
Path: /
76-
Policies:
77-
- PolicyName: root
78-
PolicyDocument:
79-
Version: 2012-10-17
80-
Statement:
81-
- Effect: Allow
82-
Action:
83-
- logs:CreateLogGroup
84-
- logs:CreateLogStream
85-
- logs:PutLogEvents
86-
Resource:
87-
!Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:*
88-
GetWebsiteBucketName:
89-
Type: Custom::CustomResource
38+
cfn_nag:
39+
rules_to_suppress:
40+
- id: W35
41+
reason: "Logs bucket does not require logging configuration"
42+
- id: W51
43+
reason: "Logs bucket is private and does not require a bucket policy"
9044
Properties:
91-
ServiceToken: !GetAtt WebsiteBucketNameFunction.Arn
45+
AccessControl: LogDeliveryWrite
9246

9347
EFSFileSimpleWebsiteBucket:
9448
Type: AWS::S3::Bucket
9549
DeletionPolicy: Retain
9650
Properties:
9751
AccessControl: LogDeliveryWrite
98-
BucketName: !GetAtt GetWebsiteBucketName.Data
9952
BucketEncryption:
10053
ServerSideEncryptionConfiguration:
10154
- ServerSideEncryptionByDefault:
@@ -104,7 +57,7 @@ Resources:
10457
IndexDocument: "index.html"
10558
ErrorDocument: "index.html"
10659
LoggingConfiguration:
107-
DestinationBucketName: !GetAtt GetWebsiteBucketName.Data
60+
DestinationBucketName: !Ref EFSFileSimpleLoggingBucket
10861
LogFilePrefix: "access_logs/"
10962
LifecycleConfiguration:
11063
Rules:
@@ -181,7 +134,7 @@ Resources:
181134
DistributionConfig:
182135
Comment: "Website distribution for Simple File Manager for EFS Solution"
183136
Logging:
184-
Bucket: !Sub "${EFSFileSimpleWebsiteBucket}.s3.amazonaws.com"
137+
Bucket: !Sub "${EFSFileSimpleLoggingBucket}.s3.amazonaws.com"
185138
Prefix: cf_logs/
186139
IncludeCookies: true
187140
Origins:

deployment/simple-file-manager-for-amazon-efs.yaml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Mappings:
2828
Data:
2929
ID: "SO0145"
3030
Version: "%%VERSION%%"
31-
AppRegistryApplicationName: "simple-file-manager-efs"
31+
AppRegistryApplicationName: "sfm"
3232
SolutionName: "Simple File Manager for Amazon EFS"
3333
ApplicationType: "AWS-Solutions"
3434
AttributeGroupName: "Solution-Metadata"
@@ -44,18 +44,19 @@ Resources:
4444
Type: AWS::ServiceCatalogAppRegistry::Application
4545
Properties:
4646
Description: Service Catalog application to track and manage all your resources. The Solution ID is SO0145 and Solution Version is %%VERSION%%.
47-
Name:
47+
Name:
4848
!Join
4949
- "-"
5050
- - !FindInMap [Solution, Data, "AppRegistryApplicationName"]
5151
- !Ref AWS::Region
5252
- !Ref AWS::AccountId
53+
- !Ref AWS::StackName
5354
Tags: {
54-
'Solutions:SolutionID': !FindInMap [Solution, Data, "ID"],
55-
'Solutions:SolutionName': !FindInMap [Solution, Data, "SolutionName"],
56-
'Solutions:SolutionVersion': !FindInMap [Solution, Data, "Version"],
57-
'Solutions:ApplicationType': !FindInMap [Solution, Data, "ApplicationType"],
58-
}
55+
'Solutions:SolutionID': !FindInMap [Solution, Data, "ID"],
56+
'Solutions:SolutionVersion': !FindInMap [Solution, Data, "Version"],
57+
'Solutions:SolutionName': !FindInMap [Solution, Data, "SolutionName"],
58+
'Solutions:ApplicationType': !FindInMap [Solution, Data, "ApplicationType"],
59+
}
5960

6061
AppRegistryApplicationStackAssociation0:
6162
Type: AWS::ServiceCatalogAppRegistry::ResourceAssociation
@@ -92,9 +93,9 @@ Resources:
9293
DefaultApplicationAttributes:
9394
Type: AWS::ServiceCatalogAppRegistry::AttributeGroup
9495
Properties:
95-
Name: !FindInMap [Solution, Data, "AttributeGroupName"]
96+
Name: !Ref AWS::StackName
9697
Description: Attribute group for solution information.
97-
Attributes:
98+
Attributes:
9899
{ "ApplicationType" : !FindInMap [Solution, Data, "ApplicationType"],
99100
"Version": !FindInMap [Solution, Data, "Version"],
100101
"SolutionID": !FindInMap [Solution, Data, "ID"],
@@ -119,6 +120,7 @@ Resources:
119120
- !FindInMap [Solution, Data, "AppRegistryApplicationName"]
120121
- !Ref AWS::Region
121122
- !Ref AWS::AccountId
123+
- !Ref AWS::StackName
122124
AutoConfigurationEnabled: true
123125
CWEMonitorEnabled: true
124126
OpsCenterEnabled: true

0 commit comments

Comments
 (0)