Adding the ability to upload to cloudfront via the 'path' parameter. Cloudfront destinations must be created separately. (#805)

Closes #277
This commit is contained in:
kevgliss 2017-05-18 13:49:17 -07:00 committed by GitHub
parent 307a73c752
commit 380203eb53
2 changed files with 11 additions and 1 deletions

View File

@ -53,7 +53,7 @@ def create_arn_from_cert(account_number, region, certificate_name):
@sts_client('iam') @sts_client('iam')
@retry(retry_on_exception=retry_throttled, stop_max_attempt_number=7, wait_exponential_multiplier=100) @retry(retry_on_exception=retry_throttled, stop_max_attempt_number=7, wait_exponential_multiplier=100)
def upload_cert(name, body, private_key, cert_chain=None, **kwargs): def upload_cert(name, body, private_key, path, cert_chain=None, **kwargs):
""" """
Upload a certificate to AWS Upload a certificate to AWS
@ -61,12 +61,14 @@ def upload_cert(name, body, private_key, cert_chain=None, **kwargs):
:param body: :param body:
:param private_key: :param private_key:
:param cert_chain: :param cert_chain:
:param path:
:return: :return:
""" """
client = kwargs.pop('client') client = kwargs.pop('client')
try: try:
if cert_chain: if cert_chain:
return client.upload_server_certificate( return client.upload_server_certificate(
Path=path,
ServerCertificateName=name, ServerCertificateName=name,
CertificateBody=str(body), CertificateBody=str(body),
PrivateKey=str(private_key), PrivateKey=str(private_key),
@ -74,6 +76,7 @@ def upload_cert(name, body, private_key, cert_chain=None, **kwargs):
) )
else: else:
return client.upload_server_certificate( return client.upload_server_certificate(
Path=path,
ServerCertificateName=name, ServerCertificateName=name,
CertificateBody=str(body), CertificateBody=str(body),
PrivateKey=str(private_key) PrivateKey=str(private_key)

View File

@ -161,6 +161,12 @@ class AWSDestinationPlugin(DestinationPlugin):
'required': True, 'required': True,
'validation': '/^[0-9]{12,12}$/', 'validation': '/^[0-9]{12,12}$/',
'helpMessage': 'Must be a valid AWS account number!', 'helpMessage': 'Must be a valid AWS account number!',
},
{
'name': 'path',
'type': 'str',
'default': '/',
'helpMessage': 'Path to upload certificate.'
} }
] ]
@ -172,6 +178,7 @@ class AWSDestinationPlugin(DestinationPlugin):
def upload(self, name, body, private_key, cert_chain, options, **kwargs): def upload(self, name, body, private_key, cert_chain, options, **kwargs):
iam.upload_cert(name, body, private_key, iam.upload_cert(name, body, private_key,
self.get_option('path', options),
cert_chain=cert_chain, cert_chain=cert_chain,
account_number=self.get_option('accountNumber', options)) account_number=self.get_option('accountNumber', options))