Commit 477ca10f authored by Marc Burnie [AWS]'s avatar Marc Burnie [AWS]
Browse files

Fixing aws bootstrapping

parent 8c0ad4a4
Pipeline #112294 passed with stages
in 13 minutes and 31 seconds
...@@ -32,8 +32,8 @@ DEFAULT_POLICIES = {'legal.rego', 'entitlements.rego', ...@@ -32,8 +32,8 @@ DEFAULT_POLICIES = {'legal.rego', 'entitlements.rego',
'dataauthz.rego', '.manifest'} 'dataauthz.rego', '.manifest'}
# Template paths # Template paths
DEFAULT_POLICIES_PATH = os.path.dirname( DEFAULT_POLICIES_PATH = os.path.dirname(os.path.dirname(os.path.dirname(
os.path.realpath(__file__)).replace('scripts\\aws', 'default-policies') os.path.realpath(__file__))))+ '/default-policies'
DEFAULT_POLICY_TEMPLATES_PATH = os.path.dirname( DEFAULT_POLICY_TEMPLATES_PATH = os.path.dirname(
os.path.realpath(__file__))+'/templates' os.path.realpath(__file__))+'/templates'
DEFAULT_POLICY_CONFIG_MAP_TEMPLATE_PATH = os.path.dirname( DEFAULT_POLICY_CONFIG_MAP_TEMPLATE_PATH = os.path.dirname(
...@@ -137,12 +137,16 @@ class AwsPolicyBootstrap: ...@@ -137,12 +137,16 @@ class AwsPolicyBootstrap:
def upsert_instance_policy_bundle(self, path: str) -> None: def upsert_instance_policy_bundle(self, path: str) -> None:
"""Creates a bundle of instance policies given the default bundle path.""" """Creates a bundle of instance policies given the default bundle path."""
file_list = []
tar_name = f'bundle.tar.gz' tar_name = f'bundle.tar.gz'
with tarfile.open(tar_name, "w:gz") as tar_handle: with tarfile.open(tar_name, "w:gz") as tar_handle:
for root, dirs, files in os.walk(path): for root, dirs, files in os.walk(path):
for file in files: for file in files:
if file in DEFAULT_POLICIES: if file in DEFAULT_POLICIES:
tar_handle.add(os.path.join(root, file), arcname=file) tar_handle.add(os.path.join(root, file), arcname=file)
file_list.append(file)
self.log.info(f"Adding files: {', '.join(file_list)} to bundle: {tar_name}")
self._upload_to_policy_bucket(tar_name) self._upload_to_policy_bucket(tar_name)
os.remove(tar_name) os.remove(tar_name)
......
...@@ -28,6 +28,6 @@ rsync deployment/* "${OUTPUT_DIR}/deployment/" ...@@ -28,6 +28,6 @@ rsync deployment/* "${OUTPUT_DIR}/deployment/"
mkdir -p "${OUTPUT_DIR}/deployment/scripts/" mkdir -p "${OUTPUT_DIR}/deployment/scripts/"
rsync deployment/scripts/* "${OUTPUT_DIR}/deployment/scripts/" rsync deployment/scripts/* "${OUTPUT_DIR}/deployment/scripts/"
mkdir -p "${OUTPUT_DIR}/deployment/default-policies/" # Need to use cp since .manifest isn't copied using rsync
rsync deployment/default-policies/* "${OUTPUT_DIR}/deployment/default-policies/" cp -r deployment/default-policies/ "${OUTPUT_DIR}/deployment/default-policies/"
cp -r deployment/scripts/aws/ "${OUTPUT_DIR}/deployment/scripts/aws/" cp -r deployment/scripts/aws/ "${OUTPUT_DIR}/deployment/scripts/aws/"
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment