This document describes the steps that project managers need to follow in order to setup development environment for their projects.
As project managers, you will need to provide enough information for your team members so that they can connect to the assigned EC2 instances and work on the projects. Please check the following checklist for preparation. You should be able to find out how to get these information in this document.
Developer Guide
Each developer will be assigned an EC2 instance for project modernization. Project manager needs to create those instances before developers start working on the project. For security reasons, all these instances are within a private network, and developers will connect to the instances through SSM. The following steps will guide project managers on how to create the instances.
Project manager needs to install CLI and session-manager-plugin on their AWS laptop:
Project manager will use a pre-defined launch template to create EC2 instances for developers. This launch template has already set up necessary configurations including network interfaces, CPU, RAM, etc. Unless there are specific requirements on the new EC2 instance(s), there will be no need to change any configurations from the template.
By clicking on the write icon in column “Name”, project manager can change the EC2 instance name to mark the assignee.
The following steps can be done by both project manager(s) and developer(s), but only explained in this manual in order to keep access controls on the instances.
net user Administrator [password-to-set] Close the browser tab, or click on “Terminate” button on top right.
If a non-Dev EC2 instance (Dev EC2 instances are launched from Launch Templates) is required for the project, project manager can create the new EC2 instances by following steps.
**ec2-<REGION>-<specificName**>”Both project managers and developers are able to stop, start and reboot an EC2 instance.
After clicking the button above, selected EC2 instance’s “Instance state” and “Status check” will change accordingly.
As termination of an EC2 instance will remove everything on the EC2 instance, including the instance configuration, termination protection is enabled by default. Project managers need to make sure everything is Okay before terminating an EC2 instance, including but not limited to:
To unlock the termination protection:
When customer account is created, there is one default launch template generated in EC2 Launch Templates list. This launch template uses the latest Dev EC2 AMI as the default AMI for creating Dev EC2 instances. However, new AMIs could be build based on needs, and project manager will need to create new launch template based on the default launch template. Please follow the steps below to create a new launch template version.
Managing EC2 Instance can be cost effective if resources are always up.
The aim of this document is to give some mechanism based on a AWS Lambda to fully schedule some resources to Start/Stop with minimal parameters.
Implementation of a solution to be deployed on all LZs that makes it possible to Start/Stop AWS resources in a certain category (based on labels) at a given time.
For now, the Lambda is able to manage 2 kind of resources:
1 - The Lambda is triggered by an EventBridge Rule scheduler.
2 - The Lambda will iterate on all resources having the specific Tag and check for current day if the resource have to be started or stopped. This configuration action is define by the value of the parameterStore specified by the Tag and must respect Scheduler configuration format
All the resources having the Tag key “bluage:resource:scheduler”: Blu Age - Landing Zone - Start/Stop EC2 Instances - User Guide will be processed.
For example, if the scheduler is set with a start at 9am and a stop at 7pm, then:
If the user needs to do additional work outside of the intended scheduler, it is possible to prevent the EC2 from automatically shutting down. Check Prevent the EC2 instance from stopping automatically
3 - At the end of the day, a report is sent by mail to the Account Manager. This report will display the state of all the account resources
To get mail, you need to opt-in the Topic Subscribe to the daily EC2 status reporting
There is 2 different rules that trigger the Lambda:
bluage:resource:scheduler
This Tag must be apply on all resources you want to schedule with Start/Stop command.
The Tag can have multiple values. The most common way to use it, is to fillup the Tag Value field with a ParameterStore key value.
The ParameterStore key/value must comply with the Scheduler configuration format
The parameters have to verify this expectation:
bluage:resource:scheduler[key in Day]?: [start: string, stop: string] | 'stopped'start/stop key pair valuestopped” value to force stop all that day long.disabled” the scheduler will not perform any action on the resource for the entire day.HHMM” format as “0600”HHMM” format as “2100”{
"Mon": ["0600", "2200"],
"Tue": ["0600", "2200"],
"Wed": ["0600", "2200"],
"Thu": ["disabled", "2200"],
"Fri": ["0600", "2200"],
"Sat": "stopped",
"Sun": "stopped"
}
Note: All the date time must be in UTC Timezone format and given by a four characters format “HHMM” (e.g. “0655”)
For instance, for EC2 resource, we set up a /bluage/resource/scheduler/EC2 parameterStore key as follow:
By default, the lambda use UTC to manage the scheduler Start/Stop processing.
The lambda can be setup to comply a specific timezone. To do so, it’s necessary to fill up the lambda environment variable “TZ”.
Go to the lambda console, then in the “configuration” tab click on the environment variables. Check the “TZ“ environment variable. If there is no value, the default UTC timezone will be apply.
To configure a french timezone, simply fill up the “TZ” value with “Europe/Paris”.
A more exhaustive timezone values can be found here
You can add your own scheduler to manage specific resources. This functionality allows you to group resources managed by a scheduler. This can be useful if some users work in different hours
For this, just add a new parameterStore
/bluage/resource/scheduler” prefix/bluage/resource/schedule/EC2-server-1Then set the new tag value to the resource you want to add the custom scheduler parameterStore
If someone needs to use its EC2 instance outside the scheduler range. It’s possible to disable the stop instance state process.
For that you have to enable the stop protection on the specific instance
Enable Stop protection
aws ec2 modify-instance-attribute \
--instance-id <instance-id> \
--disable-api-stop
Disable Stop protection
aws ec2 modify-instance-attribute \
--instance-id <instance-id> \
--no-disable-api-stop
An EventRule is provided to have project manager the ability to report daily EC2 status report.
By default, this EventRule is triggered avery day at midnight (UTC). It can be updated with a specific cron expression.
So that the project manager is notified by email of the daily report, you only have to subscribe to the reporting SNS Topic.
To do so, from the console go to the SNS Topic “LandingZone-EC2-report-topic” :
An email to confirm your subscription is sent. Just approve it then it’s done.
The CDK frugal project provide for you some default scheduling parameters.
The scheduler parameters are set in - AWS Systems Manager > ParameterStore
/bluage/resource/scheduler/EC2
{
"Mon": ["disabled", "disabled"],
"Tue": ["disabled", "disabled"],
"Wed": ["disabled", "disabled"],
"Thu": ["disabled", "disabled"],
"Fri": ["disabled", "disabled"],
"Sat": "stopped",
"Sun": "stopped"
}
/bluage/resource/scheduler/ASG
{
"Mon": ["disabled", "disabled"],
"Tue": ["disabled", "disabled"],
"Wed": ["disabled", "disabled"],
"Thu": ["disabled", "disabled"],
"Fri": ["disabled", "2000"],
"Sat": ["disabled", "disabled"],
"Sun": ["1830", "disabled"]
}
```
A Scheduled Lambda Function enables Auto Update AMI ID used by Launch Template for Dev EC2 Instances, to use the latest AWS-BluAge-SDE-Developer-ami available AMI.
Lambda function
The Lambda function is designed to update the AWS EC2 Launch Template with the latest AMI ID that matches “AWS-BluAge-SDE-Developer-ami*” pattern. It also updates an AWS Systems Manager Parameter Store parameter to store the latest AMI ID.
- Retrieves environment variables for the AMI name pattern, Parameter Store parameter name, and Launch Template name.
- Initializes AWS SDK clients for EC2 and Systems Manager (SSM).
- Checks if the specified Launch Template exists, and returns an error if it doesn't.
- Finds the latest AMI ID that matches the specified name pattern.
- Retrieves the current AMI ID from the Parameter Store parameter. If the parameter doesn't exist, it creates it with the latest AMI ID.
- Compares the latest AMI ID with the current AMI ID in the Parameter Store.
- If the AMI IDs are different, it performs the following steps:
- Creates a new version of the Launch Template with the latest AMI ID.
- Sets the new version as the default for the Launch Template.
- Updates the Parameter Store parameter with the latest AMI ID.
- Removes old Launch Template versions, keeping only the latest specified number of versions (e.g., the latest 5 versions).
- If the AMI IDs are the same, it prints a message indicating that no update is needed.
- The function returns a success message with the appropriate details.
- If any exception occurs during the execution, it catches the exception, prints the error message, and returns an error message.
SSM Parameter Store
Store the latest AMI ID available.EventBridge rule
An EventBridge rule execute the Lambda function with a cron schedule.
AMIName: default is AWS-BluAge-SDE-Developer-ami.
EventBridgeScheduleExpression: default is everyday at 3:00am. Adjust cron schedule expression if needed.
LaunchTemplateName: default is BluAge-Developer-Instance.