Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added AWS resource tagging #24

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion pipeline/aws_infra/cdk_classes/aws_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
aws_iam as iam,
RemovalPolicy,
Stack,
aws_s3 as s3
aws_s3 as s3,
Tags as cdk_tags
)

from typing import Optional
Expand Down Expand Up @@ -45,6 +46,8 @@ def __init__(self, scope: Stack, env_suffix: str, shared_work_dir_bucket: Option
removal_policy=RemovalPolicy.RETAIN,
versioned=False
)
cdk_tags.of(self.nf_workdir_bucket).add("Product", "PAVI")
cdk_tags.of(self.nf_workdir_bucket).add("Managed_by", "PAVI")
else:
self.nf_workdir_bucket = s3.Bucket.from_bucket_name(
scope=scope, id='pavi-pipeline-nf-workdir-bucket',
Expand All @@ -67,6 +70,8 @@ def __init__(self, scope: Stack, env_suffix: str, shared_work_dir_bucket: Option
)
]
)
cdk_tags.of(s3_workdir_bucket_policy_doc).add("Product", "PAVI")
cdk_tags.of(s3_workdir_bucket_policy_doc).add("Managed_by", "PAVI")

instance_role = iam.Role(scope, 'pavi-pipeline-compute-environment-instance-role',
description='Role granting permissions for Nextflow ECS execution',
Expand All @@ -78,6 +83,8 @@ def __init__(self, scope: Stack, env_suffix: str, shared_work_dir_bucket: Option
inline_policies={
's3-workdir-policy': s3_workdir_bucket_policy_doc
})
cdk_tags.of(instance_role).add("Product", "PAVI")
cdk_tags.of(instance_role).add("Managed_by", "PAVI")

ce_name = 'pavi_pipeline_ecs'
if env_suffix:
Expand All @@ -93,6 +100,11 @@ def __init__(self, scope: Stack, env_suffix: str, shared_work_dir_bucket: Option

self.compute_environment.apply_removal_policy(RemovalPolicy.DESTROY)

cdk_tags.of(self.compute_environment).add("Product", "PAVI")
cdk_tags.of(self.compute_environment).add("Managed_by", "PAVI")

self.compute_environment.tags.set_tag('Name', 'PAVI pipeline execution worker', priority=None, apply_to_launched_instances=True)

# Create the job queue
jq_name = 'pavi_pipeline'
if env_suffix:
Expand All @@ -103,3 +115,6 @@ def __init__(self, scope: Stack, env_suffix: str, shared_work_dir_bucket: Option
)

self.job_queue.add_compute_environment(self.compute_environment, order=1) # type: ignore

cdk_tags.of(self.job_queue).add("Product", "PAVI")
cdk_tags.of(self.job_queue).add("Managed_by", "PAVI")
7 changes: 6 additions & 1 deletion pipeline/aws_infra/cdk_classes/cdk_infra_stack.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from aws_cdk import (
Stack,
aws_ecr as ecr
aws_ecr as ecr,
Tags as cdk_tags
)

from constructs import Construct
Expand Down Expand Up @@ -39,12 +40,16 @@ def __init__(self, scope: Construct, construct_id: str, env_suffix: str = "",
env_suffix=env_suffix)
else:
self.seq_retrieval_ecr_repo = ecr.Repository.from_repository_name(self, id='PAVI-pipeline-seq-retrieval-repo', repository_name=shared_seq_retrieval_image_repo)
cdk_tags.of(self.seq_retrieval_ecr_repo).add("Product", "PAVI")
cdk_tags.of(self.seq_retrieval_ecr_repo).add("Managed_by", "PAVI")

# Import or create shared_alignment_image_repo
if not shared_alignment_image_repo:
self.alignment_ecr_repo = PaviEcrRepository(self, id='PAVI-pipeline-alignment-repo', component_name='pipeline_alignment',
env_suffix=env_suffix)
else:
self.alignment_ecr_repo = ecr.Repository.from_repository_name(self, id='PAVI-pipeline-alignment-repo', repository_name=shared_alignment_image_repo)
cdk_tags.of(self.alignment_ecr_repo).add("Product", "PAVI")
cdk_tags.of(self.alignment_ecr_repo).add("Managed_by", "PAVI")

self.execution_environment = PaviExecutionEnvironment(self, env_suffix=env_suffix, shared_work_dir_bucket=shared_work_dir_bucket)