Example #1
0
def main():
  account_id = '135090458419'
  account_alias = '0d08b0ac664c432ba4265de479ecfee4'
  aws = AWSIAMPolicy(account_alias, 'safe-deposit-box', 'lock_domain',
                     'data_domain', 'group0')

  iam_connection = boto.connect_iam()
  # account_alias = get_random_uuid()
  # print "Account alias:", account_alias
  # iam_connection.create_account_alias(account_alias)
  group_name = get_random_uuid()
  print "Group name:", group_name
  iam_connection.create_group(group_name)
  iam_connection.put_group_policy(group_name, group_name + '-policy',
                                  aws.json_policy())
Example #2
0
def first_time():
  # Clear internal databases' directory.
  _rm_rf(FLAGS.internal_directory)

  # Make internal databases' directory.
  os.makedirs(FLAGS.internal_directory)

  # Create connections for different AWS services.
  s3_connection = boto.connect_s3(
    aws_access_key_id = FLAGS.aws_access_key_id,
    aws_secret_access_key = FLAGS.aws_secret_access_key)
  sdb_connection = boto.connect_sdb(
    aws_access_key_id = FLAGS.aws_access_key_id,
    aws_secret_access_key = FLAGS.aws_secret_access_key)
  sqs_connection = boto.connect_sqs(
    aws_access_key_id = FLAGS.aws_access_key_id,
    aws_secret_access_key = FLAGS.aws_secret_access_key)
  sns_connection = boto.connect_sns(
    aws_access_key_id = FLAGS.aws_access_key_id,
    aws_secret_access_key = FLAGS.aws_secret_access_key)
  iam_connection = boto.connect_iam(
    aws_access_key_id = FLAGS.aws_access_key_id,
    aws_secret_access_key = FLAGS.aws_secret_access_key)

  # Creates notification service topics and queues.
  group_manager = GroupManager(sns_connection, sqs_connection, iam_connection,
                               database_directory = FLAGS.internal_directory)

  group_id = get_random_uuid()

  # Creates S3 Bucket.
  bucket_name = group_id
  blob_store = BlobStore(s3_connection, bucket_name)
  assert isinstance(blob_store.bucket, boto.s3.bucket.Bucket)

  # Creates SimpleDB domains.
  data_domain_name = bucket_name + '_data'
  lock_domain_name = bucket_name + '_locks'
  metadata_store = MetadataStore(sdb_connection, lock_domain_name,
                                 data_domain_name,
                                 database_directory = FLAGS.internal_directory)

  # Credentials table.
  credentials = Credentials(database_directory = FLAGS.internal_directory)
  if not credentials.set_credentials(group_id, 'us-east-1',
                                     FLAGS.namespace, FLAGS.aws_access_key_id,
                                     FLAGS.aws_secret_access_key, 'OWNER'):
    logging.error('We were unable to set our own owner credentials.')
Example #3
0
 def _lock_name(object_path_hash):
   return '%s-lock-%s' % (object_path_hash, get_random_uuid())