Skip to content

Commit

Permalink
👍 update
Browse files Browse the repository at this point in the history
  • Loading branch information
shun198 committed Aug 20, 2024
1 parent 7ddce5f commit 4015098
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 36 deletions.
12 changes: 6 additions & 6 deletions templates/containers/ecr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Metadata:
- Label:
default: 'ECR Configuration'
Parameters:
- BackEndAppRepositorySuffix
- BackEndWebRepositorySuffix
- BackendAppRepositorySuffix
- BackendWebRepositorySuffix

# -------------------------------------
# Input parameters
Expand All @@ -36,11 +36,11 @@ Parameters:
- stg
- prd
ConstraintDescription: 'Environment must be select.'
BackEndAppRepositorySuffix:
BackendAppRepositorySuffix:
Description: 'Repository name suffix of the application container image. (ex: django)'
Type: String
Default: django
BackEndWebRepositorySuffix:
BackendWebRepositorySuffix:
Description: 'Repository name suffix of the webserver container image. (ex: nginx)'
Type: String
Default: nginx
Expand All @@ -54,7 +54,7 @@ Resources:
UpdateReplacePolicy: Retain
Type: AWS::ECR::Repository
Properties:
RepositoryName: !Sub ${ProjectName}/${Environment}/back/${BackEndAppRepositorySuffix}
RepositoryName: !Sub ${ProjectName}/${Environment}/back/${shun198}
ImageScanningConfiguration:
ScanOnPush: true
ImageTagMutability: IMMUTABLE
Expand All @@ -68,7 +68,7 @@ Resources:
UpdateReplacePolicy: Retain
Type: AWS::ECR::Repository
Properties:
RepositoryName: !Sub ${ProjectName}/${Environment}/back/${BackEndWebRepositorySuffix}
RepositoryName: !Sub ${ProjectName}/${Environment}/back/${BackendWebRepositorySuffix}
ImageScanningConfiguration:
ScanOnPush: true
ImageTagMutability: IMMUTABLE
Expand Down
4 changes: 2 additions & 2 deletions templates/environment/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ Parameters:
Default: 2
AllowedValues: [0, 1, 2]
RDSDBName:
Description: "Enter the database name (ex: factor_flow_master_development)"
Description: "Enter the database name (ex: shun198_development)"
Type: String
RDSDBMasterUserName:
Description: "Enter the master username (postgres)"
Expand All @@ -358,7 +358,7 @@ Parameters:
AllowedPattern: "^[a-zA-Z][a-zA-Z_0-9]*"
ConstraintDescription: "Must begin with a letter and contain only alphanumeric characters"
RDSDBMasterUserPassword:
Description: "Enter the master password (postgres)"
Description: "Enter the master password (Postgres123)"
Type: String
NoEcho: true
MinLength: 10
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
AWSTemplateFormatVersion: 2010-09-09
Description: "CloudWatch Logs Stack For Backend"

# -------------------------------------
# Mappings
# -------------------------------------
Mappings:
# ロググループの保持期間
RetentionInDaysMap:
Environment:
dev: 30
stg: 60
prd: 90

# -------------------------------------
# Metadata
# -------------------------------------
Expand All @@ -25,35 +14,41 @@ Metadata:
- ProjectName
- Environment
- Label:
default: "CloudWatch Logs Configuration for ECS"
default: "CloudWatch Logs Configuration for ECS Fargate"
Parameters:
- AppLogGroupName
- WebLogGroupName
- BackendAppLogGroupName
- BackendWebLogGroupName
- LogRetentionInDays

# -------------------------------------
# Input parameters
# Parameters
# -------------------------------------
Parameters:
ProjectName:
Description: "Enter the project name. (ex: shun198)"
Type: String
MinLength: 1
ConstraintDescription: "ProjectName must be enter."
ConstraintDescription: "ProjectName must be entered."
Default: shun198
Environment:
Description: "Select the environment."
Description: "Select the environment name."
Type: String
AllowedValues:
- dev
- stg
- prd
ConstraintDescription: "Environment must be select."
AppLogGroupName:
Description: "CloudWatch Logs log-group name for application. (ex: /ecs/shun198/dev/back/django)"
ConstraintDescription: "Environment name must be selected."
BackendAppLogGroupName:
Description: "CloudWatch Logs log-group name for application. (ex: /ecs/shun198/<environment>/back/django)"
Type: String
BackendWebLogGroupName:
Description: "CloudWatch Logs log-group name for webserver. (ex: /ecs/shun198/<environment>/back/nginx)"
Type: String
WebLogGroupName:
Description: "CloudWatch Logs log-group name for webserver. (ex: /ecs/shun198/dev/back/nginx)"
LogRetentionInDays:
Description: "Enter the data retention period."
Type: String
Default: 30
AllowedValues: [30, 60, 90]

# -------------------------------------
# Resources
Expand All @@ -68,9 +63,8 @@ Resources:
UpdateReplacePolicy: Retain
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Ref AppLogGroupName
RetentionInDays:
!FindInMap [RetentionInDaysMap, Environment, !Ref Environment]
LogGroupName: !Ref BackendAppLogGroupName
RetentionInDays: !Ref LogRetentionInDays
Tags:
- Key: ProjectName
Value: !Ref ProjectName
Expand All @@ -82,11 +76,25 @@ Resources:
UpdateReplacePolicy: Retain
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Ref WebLogGroupName
RetentionInDays:
!FindInMap [RetentionInDaysMap, Environment, !Ref Environment]
LogGroupName: !Ref BackendWebLogGroupName
RetentionInDays: !Ref LogRetentionInDays
Tags:
- Key: ProjectName
Value: !Ref ProjectName
- Key: Environment
Value: !Ref Environment

# -------------------------------------
# Metric Filter
# -------------------------------------
ErrorInBackendWebLogs:
Type: AWS::Logs::MetricFilter
DependsOn: LogGroupForWeb
Properties:
LogGroupName: !Ref BackendWebLogGroupName
FilterPattern: ?"[error]" ?"[crit]" ?"[alert]" ?"[emerg]"
MetricTransformations:
- DefaultValue: 0
MetricValue: 1
MetricNamespace: Backend/Logs
MetricName: ErrorInBackendWebLogs

0 comments on commit 4015098

Please sign in to comment.