Best Python code snippet using lisa_python
platform_.py
Source:platform_.py  
...165            AwsPlatformSchema166        )167        assert aws_runbook, "platform runbook cannot be empty"168        self._aws_runbook = aws_runbook169        self._initialize_credential()170        # boto3 client is thread safe171        self._ec2_client = boto3.client("ec2")172    def _initialize_credential(self) -> None:173        aws_runbook = self._aws_runbook174        if aws_runbook.aws_access_key_id:175            os.environ["AWS_ACCESS_KEY_ID"] = aws_runbook.aws_access_key_id176        if aws_runbook.aws_secret_access_key:177            os.environ["AWS_SECRET_ACCESS_KEY"] = aws_runbook.aws_secret_access_key178        if aws_runbook.aws_session_token:179            os.environ["AWS_SESSION_TOKEN"] = aws_runbook.aws_session_token180        if aws_runbook.aws_default_region:181            os.environ["AWS_DEFAULT_REGION"] = aws_runbook.aws_default_region182    def _create_key_pair(self, key_name: str, private_key_file: str) -> Any:183        try:184            ec2_resource = boto3.resource("ec2")185            key_pair = ec2_resource.import_key_pair(186                KeyName=key_name,...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
