Standardize all of the AWS credentials
This commit is contained in:
parent
686ef55e40
commit
cc3de11e54
@ -492,8 +492,8 @@ class AWSCloudProvider(CloudProviderInterface):
|
|||||||
|
|
||||||
self.boto3 = boto3
|
self.boto3 = boto3
|
||||||
|
|
||||||
def root_creds():
|
def root_creds(self):
|
||||||
return {"username": self.access_key_id, "password": self.secret_key}
|
return {"AccessKeyId": self.access_key_id, "SecretAccessKey": self.secret_key}
|
||||||
|
|
||||||
def create_environment(
|
def create_environment(
|
||||||
self, auth_credentials: Dict, user: User, environment: Environment
|
self, auth_credentials: Dict, user: User, environment: Environment
|
||||||
@ -503,9 +503,7 @@ class AWSCloudProvider(CloudProviderInterface):
|
|||||||
|
|
||||||
# Create an account. Requires organizations:CreateAccount permission
|
# Create an account. Requires organizations:CreateAccount permission
|
||||||
account_request = org_client.create_account(
|
account_request = org_client.create_account(
|
||||||
Email=user.email,
|
Email=user.email, AccountName=uuid4().hex, IamUserAccessToBilling="ALLOW"
|
||||||
AccountName=uuid4().hex,
|
|
||||||
IamUserAccessToBilling="ALLOW",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Configuration for our CreateAccount Waiter.
|
# Configuration for our CreateAccount Waiter.
|
||||||
@ -618,8 +616,8 @@ class AWSCloudProvider(CloudProviderInterface):
|
|||||||
"AccessKey"
|
"AccessKey"
|
||||||
]
|
]
|
||||||
credentials = {
|
credentials = {
|
||||||
"key": access_key["AccessKeyId"],
|
"AccessKeyId": access_key["AccessKeyId"],
|
||||||
"secret_key": access_key["SecretAccessKey"],
|
"SecretAccessKey": access_key["SecretAccessKey"],
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: Create real policies in account.
|
# TODO: Create real policies in account.
|
||||||
@ -674,13 +672,13 @@ class AWSCloudProvider(CloudProviderInterface):
|
|||||||
A helper for creating a client of a given AWS service.
|
A helper for creating a client of a given AWS service.
|
||||||
"""
|
"""
|
||||||
credentials = credentials or {
|
credentials = credentials or {
|
||||||
"aws_access_key_id": self.access_key_id,
|
"AccessKeyId": self.access_key_id,
|
||||||
"aws_secret_access_key": self.secret_key,
|
"SecretAccessKey": self.secret_key,
|
||||||
}
|
}
|
||||||
return self.boto3.client(
|
return self.boto3.client(
|
||||||
service,
|
service,
|
||||||
aws_access_key_id=credentials["aws_access_key_id"],
|
aws_access_key_id=credentials["AccessKeyId"],
|
||||||
aws_secret_access_key=credentials["aws_secret_access_key"],
|
aws_secret_access_key=credentials["SecretAccessKey"],
|
||||||
region_name=self.region_name,
|
region_name=self.region_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from atst.domain.csp.cloud import EnvironmentCreationException
|
from atst.domain.csp.cloud import EnvironmentCreationException
|
||||||
|
from atst.jobs import (
|
||||||
|
do_create_environment,
|
||||||
|
do_create_atat_admin_user,
|
||||||
|
do_create_environment_baseline,
|
||||||
|
)
|
||||||
|
|
||||||
# pylint: disable=unused-import
|
# pylint: disable=unused-import
|
||||||
from tests.mock_boto3 import mock_aws, mock_boto3, AUTH_CREDENTIALS
|
from tests.mock_boto3 import mock_aws, mock_boto3, AUTH_CREDENTIALS
|
||||||
@ -63,3 +68,27 @@ def test_create_environment_baseline_when_policy_already_exists(mock_aws):
|
|||||||
AUTH_CREDENTIALS, "csp_environment_id"
|
AUTH_CREDENTIALS, "csp_environment_id"
|
||||||
)
|
)
|
||||||
assert "policies" in baseline_info
|
assert "policies" in baseline_info
|
||||||
|
|
||||||
|
|
||||||
|
def test_aws_provision_environment(mock_aws, session):
|
||||||
|
environment = EnvironmentFactory.create()
|
||||||
|
|
||||||
|
do_create_environment(mock_aws, environment_id=environment.id)
|
||||||
|
do_create_atat_admin_user(mock_aws, environment_id=environment.id)
|
||||||
|
do_create_environment_baseline(mock_aws, environment_id=environment.id)
|
||||||
|
|
||||||
|
session.refresh(environment)
|
||||||
|
|
||||||
|
assert "account-id" == environment.cloud_id
|
||||||
|
assert {
|
||||||
|
"id": "user-id",
|
||||||
|
"username": "user-name",
|
||||||
|
"credentials": {
|
||||||
|
"AccessKeyId": "access-key-id",
|
||||||
|
"SecretAccessKey": "secret-access-key",
|
||||||
|
},
|
||||||
|
"resource_id": "user-arn",
|
||||||
|
} == environment.root_user_info
|
||||||
|
assert {
|
||||||
|
"policies": [{"BillingReadOnly": "policy-arn"}]
|
||||||
|
} == environment.baseline_info
|
||||||
|
Loading…
x
Reference in New Issue
Block a user