Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
commit: cloudnativedaysjp/dreamkast@b64967e

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
1 parent 3b7a9f4 commit e7d2633
Show file tree
Hide file tree
Showing 18 changed files with 465 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ecspresso/reviewapps/dk-2461/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -e -o pipefail
cd $(dirname $0)

find . -name "ecspresso.jsonnet" | xargs -I{} -P10 ecspresso --config={} delete --force --terminate ||:
sleep 10 # wait for ECS Services to be deleted
aws events describe-rule --name dk-2461-harvestjob && aws events delete-rule --name dk-2461-harvestjob --force
aws ecs describe-task-definition --task-definition dreamkast-dev-dk-2461-harvestjob && aws ecs deregister-task-definition --task-definition dreamkast-dev-dk-2461-harvestjob
aws servicediscovery get-service --id srv-eqslq5r6ij43iolw && aws servicediscovery delete-service --id srv-eqslq5r6ij43iolw
aws servicediscovery get-service --id srv-662ncp7zikm3u5if && aws servicediscovery delete-service --id srv-662ncp7zikm3u5if
aws elbv2 describe-rules --rule-arn arn:aws:elasticloadbalancing:us-west-2:607167088920:listener-rule/app/dreamkast-dev/122c5b4a47b64f9d/bc86e7b2e4bca8f5/0cc93dad4e6035cd && aws elbv2 delete-rule --rule-arn arn:aws:elasticloadbalancing:us-west-2:607167088920:listener-rule/app/dreamkast-dev/122c5b4a47b64f9d/bc86e7b2e4bca8f5/0cc93dad4e6035cd
aws elbv2 describe-target-groups --target-group-arn arn:aws:elasticloadbalancing:us-west-2:607167088920:targetgroup/dev-dk-2461/653258cc5e97c8ff && aws elbv2 delete-target-group --target-group-arn arn:aws:elasticloadbalancing:us-west-2:607167088920:targetgroup/dev-dk-2461/653258cc5e97c8ff
:
48 changes: 48 additions & 0 deletions ecspresso/reviewapps/dk-2461/const.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
PR_NAME: 'dk-2461',
cluster: 'dreamkast-dev',
executionRoleName: 'dreamkast-dev-ecs-task-execution-role',
externalEndpoints: {
dkApi: 'https://api.dev.cloudnativedays.jp',
dkWeaver: 'https://dkw.dev.cloudnativedays.jp',
},
imageTags: {
dreamkast_ecs: 'b64967e9cd43e69f3e40dd086f8d3641267ceb79',
mysql: '8.0.33',
redis: '6.0',
},
internalEndpoints: {
rdb: 'mysql-dk-2461.development.local',
redis: 'redis://redis-dk-2461.development.local',
},
publicSubnetIDs: [
'subnet-00709135a42bf907e',
'subnet-0d07831c8fc073511',
'subnet-033491d41490494b6',
],
region: 'us-west-2',
s3: {
dreamkast: {
name: 'dreamkast-dev-bucket',
region: 'us-west-2',
},
},
secretManager: {
dk: 'dreamkast/reviewapp-env-yGJKrj',
railsApp: 'dreamkast/rails-app-secret-SqidNC',
},
sentry: {
dsn: 'TODO',
},
serviceDiscovery: {
mysql: 'srv-eqslq5r6ij43iolw',
redis: 'srv-662ncp7zikm3u5if',
},
sqs: {
fifo: 'dreamkast-stg-fifo-queue',
},
targetGroupArn: {
dk: 'arn:aws:elasticloadbalancing:us-west-2:607167088920:targetgroup/dev-dk-2461/653258cc5e97c8ff',
},
taskTargetRoleName: 'dreamkast-dev-ecs-scheduled-task-target-role',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
local const = import '../const.libsonnet';
{
region: const.region,
cluster: const.cluster,
service: '%s-dreamkast-fifo-worker' % [const.PR_NAME],
service_definition: 'service-def.jsonnet',
task_definition: 'task-def.jsonnet',
timeout: '10m',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local dreamkast_fifo_worker = import '../../../base/dreamkast-fifo-worker.libsonnet';
local const = import '../const.libsonnet';

dreamkast_fifo_worker.serviceDef(
region=const.region,
subnetIDs=const.publicSubnetIDs,
securityGroupID='sg-0140d2aeaaa5d6d07', // dreamkast-dev-ecs-dreamkast-fifo-worker
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
local dreamkast_fifo_worker = import '../../../base/dreamkast-fifo-worker.libsonnet';
local const = import '../const.libsonnet';

dreamkast_fifo_worker.taskDef(
family='dreamkast-dev-%s-fifo-worker' % [const.PR_NAME],
taskRoleName='dreamkast-dev-ecs-dreamkast-fifo-worker',
executionRoleName=const.executionRoleName,
imageTag=const.imageTags.dreamkast_ecs,

region=const.region,
rdbInternalEndpoint=const.internalEndpoints.rdb,
redisInternalEndpoint=const.internalEndpoints.redis,

s3BucketName=const.s3.dreamkast.name,
s3BucketRegion=const.s3.dreamkast.region,

sqsFifoQueueName=const.sqs.fifo,

sentryDsn=const.sentry.dsn,

railsAppSecretManagerName=const.secretManager.railsApp,
rdsSecretManagerName=const.secretManager.rds,
dreamkastSecretManagerName=const.secretManager.dk,

enableLogging=true,
reviewapp=true,
)
9 changes: 9 additions & 0 deletions ecspresso/reviewapps/dk-2461/dreamkast/ecspresso.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
local const = import '../const.libsonnet';
{
region: const.region,
cluster: const.cluster,
service: '%s-dreamkast' % [const.PR_NAME],
service_definition: 'service-def.jsonnet',
task_definition: 'task-def.jsonnet',
timeout: '10m',
}
9 changes: 9 additions & 0 deletions ecspresso/reviewapps/dk-2461/dreamkast/service-def.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
local dreamkast_dk = import '../../../base/dreamkast.libsonnet';
local const = import '../const.libsonnet';

dreamkast_dk.serviceDef(
region=const.region,
subnetIDs=const.publicSubnetIDs,
securityGroupID='sg-00e734fea020b954d', // dreamkast-dev-ecs-dreamkast
targetGroupArn=const.targetGroupArn.dk,
)
29 changes: 29 additions & 0 deletions ecspresso/reviewapps/dk-2461/dreamkast/task-def.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
local dreamkast = import '../../../base/dreamkast.libsonnet';
local const = import '../const.libsonnet';

dreamkast.taskDef(
family='dreamkast-dev-%s-dk' % [const.PR_NAME],
taskRoleName='dreamkast-dev-ecs-dreamkast',
executionRoleName=const.executionRoleName,
imageTag=const.imageTags.dreamkast_ecs,

region=const.region,
dkApiEndpoint=const.externalEndpoints.dkApi,
dkWeaverEndpoint=const.externalEndpoints.dkWeaver,
rdbInternalEndpoint=const.internalEndpoints.rdb,
redisInternalEndpoint=const.internalEndpoints.redis,

s3BucketName=const.s3.dreamkast.name,
s3BucketRegion=const.s3.dreamkast.region,

sqsFifoQueueName=const.sqs.fifo,

sentryDsn=const.sentry.dsn,

railsAppSecretManagerName=const.secretManager.railsApp,
rdsSecretManagerName=const.secretManager.rds,
dreamkastSecretManagerName=const.secretManager.dk,

enableLogging=true,
reviewapp=true,
)
24 changes: 24 additions & 0 deletions ecspresso/reviewapps/dk-2461/harvestjob/ecschedule.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local const = import '../const.libsonnet';
{
region: const.region,
cluster: const.cluster,
role: const.taskTargetRoleName,
rules: [
{
name: '%s-harvestjob' % [const.PR_NAME],
scheduleExpression: 'cron(*/3 * * * ? *)',
taskDefinition: 'dreamkast-dev-%s-harvestjob' % [const.PR_NAME],
launch_type: 'FARGATE',
platform_version: 'LATEST',
network_configuration: {
aws_vpc_configuration: {
subnets: const.publicSubnetIDs,
security_groups: [
'sg-05592a72e569c245b', // dreamkast-dev-ecs-harvestjob
],
assign_public_ip: 'ENABLED',
},
},
},
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local const = import '../const.libsonnet';
{
region: const.region,
cluster: const.cluster,
task_definition: 'task-def.jsonnet',
timeout: '5m',
}
114 changes: 114 additions & 0 deletions ecspresso/reviewapps/dk-2461/harvestjob/task-def.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
local const = import '../const.libsonnet';
local family = 'dreamkast-dev-%s-harvestjob' % [const.PR_NAME];
local roleName = 'dreamkast-dev-ecs-harvestjob';

{
containerDefinitions: [
{
local container = self,

name: 'dreamkast',
image: '607167088920.dkr.ecr.%s.amazonaws.com/dreamkast-ecs:%s' % [const.region, const.imageTags.dreamkast_ecs],
essential: true,
entryPoint: [
'/bin/bash',
'-c',
],
command: [
'bundle exec rake util:polling_harvest_job_and_update_video',
],
environment: [
{
name: 'RAILS_ENV',
value: 'production',
},
{
name: 'MYSQL_HOST',
value: const.internalEndpoints.rdb,
},
{
name: 'MYSQL_DATABASE',
value: 'dreamkast',
},
{
name: 'REDIS_URL',
value: const.internalEndpoints.redis,
},
{
name: 'SENTRY_DSN',
value: const.sentry.dsn,
},
{
name: 'S3_BUCKET',
value: 'dreamkast-dev-bucket',
},
{
name: 'S3_REGION',
value: const.region,
},
{
name: 'SQS_MAIL_QUEUE_URL',
value: 'https://sqs.%s.amazonaws.com/607167088920/%s.fifo' % [const.region, const.sqs.fifo],
},
{
name: 'DREAMKAST_NAMESPACE',
value: 'dreamkast-dev',
},
{
name: 'REVIEW_APP',
value: 'true',
},
],
secrets: [
{
name: 'SLACK_WEBHOOK_URL',
valueFrom: 'arn:aws:secretsmanager:%s:607167088920:secret:%s:SLACK_CHANNEL_FOR_HARVEST_JOB_NOTIFICATION::' % [const.region, const.secretManager.dk],
},
{
name: 'SLACK_CHANNEL',
valueFrom: 'arn:aws:secretsmanager:%s:607167088920:secret:%s:SLACK_CHANNEL_FOR_HARVEST_JOB_NOTIFICATION::' % [const.region, const.secretManager.dk],
},
{
name: 'RAILS_MASTER_KEY',
valueFrom: 'arn:aws:secretsmanager:%s:607167088920:secret:%s' % [const.region, const.secretManager.railsApp],
},
{
name: 'AUTH0_CLIENT_ID',
valueFrom: 'arn:aws:secretsmanager:%s:607167088920:secret:%s:AUTH0_CLIENT_ID::' % [const.region, const.secretManager.dk],
},
{
name: 'AUTH0_CLIENT_SECRET',
valueFrom: 'arn:aws:secretsmanager:%s:607167088920:secret:%s:AUTH0_CLIENT_SECRET::' % [const.region, const.secretManager.dk],
},
{
name: 'AUTH0_DOMAIN',
valueFrom: 'arn:aws:secretsmanager:%s:607167088920:secret:%s:AUTH0_DOMAIN::' % [const.region, const.secretManager.dk],
},
],

logConfiguration: {
logDriver: 'awslogs',
options: {
'awslogs-create-group': 'true',
'awslogs-group': family,
'awslogs-region': const.region,
'awslogs-stream-prefix': container.name,
},
},

cpu: 256,
memory: 512,
memoryReservation: 512,
},
],
family: family,
cpu: '256',
memory: '512',
executionRoleArn: 'arn:aws:iam::607167088920:role/%s' % [const.executionRoleName],
taskRoleArn: 'arn:aws:iam::607167088920:role/%s' % [roleName],
networkMode: 'awsvpc',
requiresCompatibilities: [
'FARGATE',
],
volumes: [],
}
Loading

0 comments on commit e7d2633

Please sign in to comment.