impl#
Runtime refers to the specific computational environment in which your code is executed. For example, running code on a local laptop, CI/CD build environments, AWS EC2 instances, AWS Lambda functions, and more. Understanding the current runtime is essential as it can impact how your code behaves.
For instance, when running your code on a local laptop, you might want to use an AWS CLI named profile to access DevOps or workload AWS accounts. However, in an application runtime like AWS Lambda, the default Boto session is typically preconfigured for the current workload AWS account.
This Python module is designed to detect the current runtime information and
offers a set of is_xyz methods to assist you in crafting conditional logic
for performing different actions based on the runtime. Notably, many of these
methods employ the LAZY LOAD technique for efficiency.
While this module is an integral part of the https://github.com/MacHu-GWU/aws_ops_alpha-project repository, it is also available for standalone use.
Requirements: Python>=3.8
Dependencies:
cached-property>=1.5.2; python_version < '3.8'
- class aws_ops_alpha.runtime.impl.RunTimeGroupEnum(value)[source]#
Enumeration of common runtime groups in AWS projects.
- class aws_ops_alpha.runtime.impl.RunTimeEnum(value)[source]#
Enumeration of common runtime in AWS projects.
- class aws_ops_alpha.runtime.impl.Runtime[source]#
Detect the current runtime information by inspecting environment variables.
The instance of this class is the entry point of all kinds of runtime related variables, methods.
You can extend this class to add more runtime detection logic.
- property is_aws_cloud9: bool#
We use “C9” environment variable to detect AWS Cloud9 runtime. Note that this method may not be stable. But you could add the
export C9=trueto the~/.bashrcor~/.bash_profile.Reference:
- property is_aws_ec2: bool#
There’s no official way to detect if it is ec2 instance, you could set a custom environment variable for all your ec2 instances
- property is_aws_ecs: bool#
There’s no official way to detect if it is ecs task container, you could set a custom environment variable for all your ECS task.
Reference: