Cake Build addin for configuring Amazon Elastic Computing
- Start Instances
- Stop Instances
- Terminate Instances
- Uses AWS fallback credentials (app.config / web.config file, SDK store or credentials file, environment variables, instance profile)
Cake.AWS.EC2 is available as a nuget package from the package manager console:
Install-Package Cake.AWS.EC2
or directly in your build script via a cake addin directive:
#addin "Cake.AWS.EC2"
#addin "Cake.AWS.EC2"
EC2Settings settings = new UploadSettings()
{
AccessKey = "blah",
SecretKey = "blah",
Region = RegionEndpoint.EUWest1
};
Task("Start-Instances")
.Description("Starts an EC2 instances.")
.Does(async () =>
{
await StartEC2Instances("instance1,instance2,instance3", settings);
});
Task("Stop-Instances")
.Description("Stops an EC2 instances.")
.Does(async () =>
{
await StopEC2Instances("instance1,instance2,instance3", settings);
});
Task("Terminate-Instances")
.Description("Terminates an EC2 instances.")
.Does(async () =>
{
await TerminateEC2Instances("instance1,instance2,instance3", settings);
});
Task("Instance-Running")
.Description("Checks an instance is running.")
.Does(async () =>
{
await IsInstanceRunning("instance1", settings);
});
Task("Instance-Stopped-Fallback")
.Description("Checks an instance is stopped, using AWS Fallback credential")
.Does(async () =>
{
await IsInstanceStopped("instance1", Context.CreateEC2Settings());
});
RunTarget("Start-Instances");
A complete Cake example can be found here.
- Please be aware of the breaking changes that occurred with the release of Cake v0.22.0, you will need to upgrade Cake in order to use Cake.AWS.EC2 v0.2.0 or above.
If your EC2 instances are behind ELB load balancers its worth checking out Cake.AWS.ElasticLoadBalancing or if your using Route53 as your DNS server check out Cake.AWS.Route53.
If your looking for a way to trigger cake tasks based on windows events or at scheduled intervals then check out CakeBoss.
Copyright (c) 2015 - 2016 Phillip Sharpe
Cake.AWS.EC2 is provided as-is under the MIT license. For more information see LICENSE.
If this project helps you in anyway then please ⭐ the repository.