Skip to content

Commit 2f63c35

Browse files
authored
MediaConvert (#7)
* wip * rename EC2 IAM things * wip * sync media convert rule and inject into .env during build * drop Elastic Transcoder logic * wip it * wip * wip * create SNS topic for mediaconvert * skip mediaconvert steps if not configured * detail some features and change transcoder in manifest * SNS subscription for Mediaconvert * create EventBridge rule and rule target * fix exceptions * ensure the default AWS profile is not used * wip * drop SNS and event bridge logic for mediaconvert * drop more mediaconvert related logic * drop WOULD_SKIP * wip
1 parent d547edf commit 2f63c35

31 files changed

+318
-279
lines changed

README.md

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,71 @@
33
> [!IMPORTANT]
44
> This package is in active development - contributions are welcome!
55
6-
YOLO helps you deploy high-availability PHP applications on AWS.
6+
YOLO helps you deploy high-availability PHP applications to AWS.
77

8-
The CLI tool takes care of provisioning and configuring all required resources on AWS, coupled with build and deployment
8+
The CLI tool lives inside your Laravel app in `vendor/bin/yolo`, and takes care of provisioning and configuring all
9+
required resources on
10+
AWS, coupled with build and deployment
911
commands to deploy applications to production from your local machine or CI pipeline.
1012

13+
YOLO has been battle-tested on apps that serve 2 million requests per day.
14+
15+
## Features
16+
17+
### Autoscaling Worker Groups
18+
19+
YOLO provisions an Application Load Balancer and autoscaling groups (web, queue, scheduler) for each environment.
20+
21+
Each group is self-healing should an instance become unresponsive, and the web group automatically scales up to handle
22+
traffic bursts.
23+
24+
In addition, worker groups can be combined (coming soon) to a single EC2 instance to consolidate small workloads.
25+
26+
### Resource Sharing
27+
28+
YOLO shares various resources between applications to reduce costs.
29+
30+
### Zero-downtime Deployments
31+
32+
YOLO leverages AWS CodeDeploy to perform zero-downtime deployments, which can be triggered from the CLI or via a CI
33+
pipeline.
34+
35+
### Multi-tenancy
36+
37+
Specify tenants in the manifest and YOLO will take care of provisioning resources for each tenant.
38+
39+
### S3
40+
41+
Leverage S3 for storing build artefacts and user data files.
42+
43+
### Octane (experimental)
44+
45+
YOLO supports Laravel Octane for turbocharged PHP applications.
46+
47+
### Video Transcoding
48+
49+
YOLO can provision resources on AWS to simplify video transcoding on AWS using AWS Elemental MediaConvert.
50+
51+
### And Much More...
52+
53+
- Least priviledge permissions with strong segregation across environments and apps
54+
- Seperate commands that run on deployment across worker groups
55+
- Scheduled MySQL backups using `mysqldump`
56+
- Control of build and deploy commands
57+
- Re-use existing VPCs, subnets, internet gateways and more
58+
1159
___
1260

1361
## Disclaimer
1462

15-
YOLO is designed for PHP developers who want to manage AWS using an infrastructure-as-code approach, using plain-old PHP
16-
rather than CloudFormation / Terraform / K8s / Elastic Beanstalk / <some-other-fancy-alternative>.
63+
YOLO is designed for PHP developers who are comfortable managing AWS using an infrastructure-as-code approach.
1764

18-
> [!IMPORTANT]
19-
> While YOLO has been battle-tested on apps serving millions of requests per day, it is not supposed to be a
20-
> set-and-forget solution for busy apps, but rather allows you to proactively manage, grow and adapt your infrastructure
21-
> as requirements change over time.
65+
It is, at it's core, a Symfony CLI app that leverages the AWS SDK, rather than CloudFormation / Terraform / K8s /
66+
Elastic
67+
Beanstalk / <some-other-fancy-alternative>.
68+
69+
While YOLO has underpinned very large, mission-critical production applications, it is not intended to be a set and
70+
forget solution; rather it acts as a control plane that allows you to manage and expand your AWS footprint over time.
2271

2372
It goes without saying, but use YOLO at your own risk.
2473

@@ -173,7 +222,7 @@ environments:
173222
artefacts-bucket:
174223
cloudfront:
175224
alb:
176-
transcoder: false
225+
mediaconvert: false
177226
autoscaling:
178227
web:
179228
queue:

src/Aws.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Aws\CloudWatch\CloudWatchClient;
1616
use Aws\CodeDeploy\CodeDeployClient;
1717
use Aws\AutoScaling\AutoScalingClient;
18-
use Aws\ElasticTranscoder\ElasticTranscoderClient;
1918
use Aws\ElasticLoadBalancingV2\ElasticLoadBalancingV2Client;
2019

2120
class Aws
@@ -97,11 +96,6 @@ public static function elasticLoadBalancingV2(): ElasticLoadBalancingV2Client
9796
return Helpers::app('elasticLoadBalancingV2');
9897
}
9998

100-
public static function elasticTranscoder(): ElasticTranscoderClient
101-
{
102-
return Helpers::app('elasticTranscoder');
103-
}
104-
10599
public static function iam(): IamClient
106100
{
107101
return Helpers::app('iam');

src/AwsResources.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Codinglabs\Yolo\Concerns\UsesCloudWatch;
1414
use Codinglabs\Yolo\Concerns\UsesCodeDeploy;
1515
use Codinglabs\Yolo\Concerns\UsesAutoscaling;
16-
use Codinglabs\Yolo\Concerns\UsesElasticTranscoder;
1716
use Codinglabs\Yolo\Concerns\UsesCertificateManager;
1817
use Codinglabs\Yolo\Concerns\UsesElasticLoadBalancingV2;
1918

@@ -25,7 +24,6 @@ class AwsResources
2524
use UsesCodeDeploy;
2625
use UsesEc2;
2726
use UsesElasticLoadBalancingV2;
28-
use UsesElasticTranscoder;
2927
use UsesIam;
3028
use UsesRds;
3129
use UsesRoute53;

src/Commands/DeployCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class DeployCommand extends SteppedCommand
1515
{
1616
protected array $steps = [
17-
Steps\Ensures\EnsureTranscoderExistsStep::class,
17+
Steps\Ensures\EnsureIamRolesExistStep::class,
1818
Steps\Ensures\EnsureHostedZonesExistStep::class,
1919
Steps\Ensures\EnsureMultitenancyHostedZonesExistStep::class,
2020
Steps\Ensures\EnsureEnvIsConfiguredCorrectlyStep::class,

src/Commands/SyncComputeCommand.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ class SyncComputeCommand extends SteppedCommand
2020
// // multitenancy
2121
// Steps\Compute\SyncMultitenancyListenerOnPort443Step::class,
2222
// Steps\Compute\AttachMultitenancySslCertificateToLoadBalancerListenerStep::class,
23-
24-
// transcoder
25-
Steps\Compute\SyncElasticTranscoderPipelineStep::class,
26-
Steps\Compute\SyncElasticTranscoderPresetStep::class,
2723
];
2824

2925
protected function configure(): void

src/Commands/SyncIamCommand.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
class SyncIamCommand extends SteppedCommand
99
{
1010
protected array $steps = [
11-
Steps\Iam\SyncRoleStep::class,
12-
Steps\Iam\SyncRolePolicyStep::class,
13-
Steps\Iam\AttachRolePoliciesStep::class,
14-
Steps\Iam\SyncInstanceProfileStep::class,
15-
Steps\Iam\AttachRoleToInstanceProfileStep::class,
11+
Steps\Iam\SyncEc2RoleStep::class,
12+
Steps\Iam\SyncEc2RolePolicyStep::class,
13+
Steps\Iam\AttachEc2RolePoliciesStep::class,
14+
Steps\Iam\SyncEc2InstanceProfileStep::class,
15+
Steps\Iam\AttachEc2RoleToInstanceProfileStep::class,
16+
Steps\Iam\SyncMediaConvertRoleStep::class,
17+
Steps\Iam\AttachMediaConvertRolePoliciesStep::class,
1618
];
1719

1820
protected function configure(): void

src/Commands/SyncNetworkCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SyncNetworkCommand extends SteppedCommand
3232
Steps\Network\SyncRdsSecurityGroupStep::class,
3333

3434
// sns
35-
Steps\Network\SyncSnsTopicStep::class,
35+
Steps\Network\SyncSnsAlarmTopicStep::class,
3636

3737
// ssh
3838
Steps\Network\SyncKeyPairStep::class,

src/Concerns/RegistersAws.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use Codinglabs\Yolo\Enums\ServerGroup;
2323
use Aws\Credentials\CredentialProvider;
2424
use GuzzleHttp\Exception\ConnectException;
25-
use Aws\ElasticTranscoder\ElasticTranscoderClient;
25+
use Codinglabs\Yolo\Exceptions\IntegrityCheckException;
2626
use Aws\ElasticLoadBalancingV2\ElasticLoadBalancingV2Client;
2727

2828
trait RegistersAws
@@ -43,7 +43,6 @@ protected function registerAwsServices(): void
4343
Helpers::app()->singleton('cloudWatch', fn () => new CloudWatchClient($arguments));
4444
Helpers::app()->singleton('ec2', fn () => new Ec2Client($arguments));
4545
Helpers::app()->singleton('elasticLoadBalancingV2', fn () => new ElasticLoadBalancingV2Client($arguments));
46-
Helpers::app()->singleton('elasticTranscoder', fn () => new ElasticTranscoderClient($arguments));
4746
Helpers::app()->singleton('iam', fn () => new IamClient($arguments));
4847
Helpers::app()->singleton('rds', fn () => new RdsClient($arguments));
4948
Helpers::app()->singleton('route53', fn () => new Route53Client($arguments));
@@ -66,14 +65,20 @@ protected static function awsCredentials(): callable|array|null
6665
return null;
6766
}
6867

69-
// in CI (GitHub Actions) we use environment variables, otherwise we
70-
// are using a local env value to point to the correct AWS profile.
71-
return static::detectCiEnvironment()
72-
? [
68+
// in CI (GitHub Actions) we use environment variables
69+
if (static::detectCiEnvironment()) {
70+
return [
7371
'key' => env('AWS_ACCESS_KEY_ID'),
7472
'secret' => env('AWS_SECRET_ACCESS_KEY'),
75-
]
76-
: CredentialProvider::ini(Helpers::keyedEnv('AWS_PROFILE'));
73+
];
74+
}
75+
76+
// otherwise we are using a local env value to point to the correct AWS profile.
77+
if (in_array(Helpers::keyedEnv('AWS_PROFILE'), ['', null, 'default'])) {
78+
throw new IntegrityCheckException(sprintf('Using the default AWS profile in your credentials file is risky. Name your profile to something specific and update %s in your .env file before proceeding.', Helpers::keyedEnvName('AWS_PROFILE')));
79+
}
80+
81+
return CredentialProvider::ini(Helpers::keyedEnv('AWS_PROFILE'));
7782
}
7883

7984
protected static function detectLocalEnvironment(): bool

src/Concerns/RunsSteppedCommands.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ protected function handleSteps(string $environment): int
7171

7272
// yellow
7373
StepResult::SKIPPED => '<fg=yellow>SKIPPED</>',
74-
StepResult::WOULD_SKIP => '<fg=yellow>WOULD SKIP</>',
7574
StepResult::CUSTOM_MANAGED => '<fg=yellow>CUSTOM MANAGED</>',
7675
StepResult::WOULD_CREATE => '<fg=yellow>WOULD CREATE</>',
7776
StepResult::WOULD_SYNC => '<fg=yellow>WOULD SYNC</>',
@@ -152,7 +151,7 @@ protected static function normaliseStep(Step $step, $pad = false, $bold = false,
152151
->when($bold && ! $step instanceof ExecutesTenantStep, fn (Stringable $string) => $string->wrap(before: '<options=bold>', after: '</>'))
153152
};
154153

155-
return $name->limit(50)
156-
->when($pad, fn (Stringable $string) => $string->padRight(50));
154+
return $name->limit(70)
155+
->when($pad, fn (Stringable $string) => $string->padRight(70));
157156
}
158157
}

src/Concerns/UsesElasticTranscoder.php

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)