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')
@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
@ -61,12 +61,14 @@ def upload_cert(name, body, private_key, cert_chain=None, **kwargs):
:param body:
:param private_key:
:param cert_chain:
:param path:
:return:
"""
client = kwargs.pop('client')
try:
if cert_chain:
return client.upload_server_certificate(
Path=path,
ServerCertificateName=name,
CertificateBody=str(body),
PrivateKey=str(private_key),
@ -74,6 +76,7 @@ def upload_cert(name, body, private_key, cert_chain=None, **kwargs):
)
else:
return client.upload_server_certificate(
Path=path,
ServerCertificateName=name,
CertificateBody=str(body),
PrivateKey=str(private_key)

View File

@ -161,6 +161,12 @@ class AWSDestinationPlugin(DestinationPlugin):
'required': True,
'validation': '/^[0-9]{12,12}$/',
'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):
iam.upload_cert(name, body, private_key,
self.get_option('path', options),
cert_chain=cert_chain,
account_number=self.get_option('accountNumber', options))