import boto3


class Helpers(object):
    """A container class for convenience functions."""

    _aws_account_id = None

    @classmethod
    def aws_account_id(cls):
        """Query for the current account ID by inspecting the default security group."""
        if cls._aws_account_id is None:
            cls._aws_account_id = int(boto3.client('ec2').describe_security_groups(
                GroupNames=['default'])['SecurityGroups'][0]['OwnerId'])
        return cls._aws_account_id

import boto3


class Helpers(object):
    """A container class for convenience functions."""

    _aws_account_id = None

    @classmethod
    def aws_account_id(cls):
        """Query for the current account ID by inspecting the caller identity."""
        if cls._aws_account_id is None:
            caller_data = boto3.client('sts').get_caller_identity()
            cls._aws_account_id = caller_data['Arn'].split(':')[4]
        return cls._aws_account_id

Use get_caller_identity instead of default SG to determine account id
Use get_caller_identity instead of default SG to determine account id

  import boto3
  
  
  class Helpers(object):
      """A container class for convenience functions."""
  
      _aws_account_id = None
  
      @classmethod
      def aws_account_id(cls):
-         """Query for the current account ID by inspecting the default security group."""
+         """Query for the current account ID by inspecting the caller identity."""
          if cls._aws_account_id is None:
-             cls._aws_account_id = int(boto3.client('ec2').describe_security_groups(
-                 GroupNames=['default'])['SecurityGroups'][0]['OwnerId'])
+             caller_data = boto3.client('sts').get_caller_identity()
+             cls._aws_account_id = caller_data['Arn'].split(':')[4]
          return cls._aws_account_id
  
Use get_caller_identity instead of default SG to determine account id
## Code Before:
import boto3


class Helpers(object):
    """A container class for convenience functions."""

    _aws_account_id = None

    @classmethod
    def aws_account_id(cls):
        """Query for the current account ID by inspecting the default security group."""
        if cls._aws_account_id is None:
            cls._aws_account_id = int(boto3.client('ec2').describe_security_groups(
                GroupNames=['default'])['SecurityGroups'][0]['OwnerId'])
        return cls._aws_account_id

## Instruction:
Use get_caller_identity instead of default SG to determine account id
## Code After:
import boto3


class Helpers(object):
    """A container class for convenience functions."""

    _aws_account_id = None

    @classmethod
    def aws_account_id(cls):
        """Query for the current account ID by inspecting the caller identity."""
        if cls._aws_account_id is None:
            caller_data = boto3.client('sts').get_caller_identity()
            cls._aws_account_id = caller_data['Arn'].split(':')[4]
        return cls._aws_account_id
