From 62dc2c3db0f814fbce8409c09fbe5854cbd88e24 Mon Sep 17 00:00:00 2001 From: Gabriel Alejandro Soltz Date: Tue, 9 Apr 2024 02:04:54 +0200 Subject: [PATCH] improve-elb-definition --- README.md | 9 +++++---- aws_arn/__init__.py | 13 +++++++++++++ aws_arn/data.py | 12 ++++++++++-- setup.py | 2 +- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2ac6294..7b029e2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # aws-arn -This repository contains a list of almost all (WIP) AWS services and resources with their **ARN format**, **ID name**, **ID regexp**, **ASFF name**, **CloudFormation resource name** and **Terraform resource name**, that you can use as [Documentation](#full-list-of-arns), as a [Python module](#python-module) or as [CLI tool](#cli-tool). +This repository contains a list of almost all (WIP) AWS services and resources with their **ARN format**, **ID name**, **ID regexp**, **ASFF name**, **CloudFormation resource name** and **Terraform resource name**, that you can use as [Documentation](#complete-list-of-arns), as a [Python module](#python-module) or as [CLI tool](#cli-tool). | AWS Services | AWS Resources | |-------------- |--------------- | @@ -119,7 +119,7 @@ arn:aws:ec2:us-east-1:012345789012:instance/i-1234568901 {'service': 'ec2', 'sub_service': 'instance', 'region': 'us-east-1', 'account': '012345789012', 'resource_id': 'i-1234568901', 'asff_resource': 'AwsEc2Instance', 'terraform': 'aws_instance', 'cloudformation': 'AWS::EC2::Instance'} ``` -## Full List of ARNs +## Complete List of ARNs | Service | Resource | ARN Format | ID Name | ID Regexp | ASFF Name | CloudFormation | Terraform | |----|----|----|----|----|----|----|----| @@ -292,7 +292,8 @@ arn:aws:ec2:us-east-1:012345789012:instance/i-1234568901 | elasticbeanstalk | application_version | `arn:{partition}:elasticbeanstalk:{region}:{account}:applicationversion/{resource_id}` | ApplicationVersionName | `([a-zA-Z0-9-_.]+)` | | AWS::ElasticBeanstalk::ApplicationVersion | aws_elastic_beanstalk_application_version | | elasticbeanstalk | environment | `arn:{partition}:elasticbeanstalk:{region}:{account}:environment/{resource_id}` | EnvironmentId | `([a-zA-Z0-9-_.]+)` | AwsElasticBeanstalkEnvironment | AWS::ElasticBeanstalk::Environment | aws_elastic_beanstalk_environment | | elb | loadbalancer | `arn:{partition}:elasticloadbalancing:{region}:{account}:loadbalancer/{resource_id}` | LoadBalancerName | `[\w.-]{1,32}` | AwsElbLoadBalancer | AWS::ElasticLoadBalancing::LoadBalancer | aws_elb | -| elbv2 | loadbalancer | `arn:{partition}:elasticloadbalancing:{region}:{account}:loadbalancer/{resource_id}` | LoadBalancerName | `[\w.-]{1,32}` | AwsElbv2LoadBalancer | AWS::ElasticLoadBalancingV2::LoadBalancer | aws_alb | +| elbv2 | app_loadbalancer | `arn:{partition}:elasticloadbalancing:{region}:{account}:loadbalancer/app/{resource_id}/{load_balancer_id}` | LoadBalancerName | `[\w.-]{1,32}` | AwsElbv2LoadBalancer | AWS::ElasticLoadBalancingV2::LoadBalancer | aws_alb | +| elbv2 | net_loadbalancer | `arn:{partition}:elasticloadbalancing:{region}:{account}:loadbalancer/net/{resource_id}/{load_balancer_id}` | LoadBalancerName | `[\w.-]{1,32}` | AwsElbv2LoadBalancer | AWS::ElasticLoadBalancingV2::LoadBalancer | aws_alb | | elbv2 | targetgroup | `arn:{partition}:elasticloadbalancing:{region}:{account}:targetgroup/{resource_id}/{targetgroup_id}` | TargetGroupID | `[\w.-]{1,32}` | | AWS::ElasticLoadBalancingV2::TargetGroup | aws_alb_target_group | | elbv2 | listener | `arn:{partition}:elasticloadbalancing:{region}:{account}:listener/{resource_id}/{load_balancer_id}/{listener_id}` | ListenerId | `(?<=listener\/app\/)[^\/]+` | | AWS::ElasticLoadBalancingV2::Listener | aws_alb_listener | | elbv2 | listener_rule | `arn:{partition}:elasticloadbalancing:{region}:{account}:listener-rule/{resource_id}` | ListenerRuleId | `[\w.-]{1,32}` | | AWS::ElasticLoadBalancingV2::ListenerRule | aws_alb_listener_rule | @@ -301,7 +302,7 @@ arn:aws:ec2:us-east-1:012345789012:instance/i-1234568901 | elasticmapreduce | step | `arn:{partition}:elasticmapreduce:{region}:{account}:cluster/{resource_id}/step/{step_id}` | StepId | `s-[0-9a-zA-Z]+` | | AWS::EMR::Step | aws_emr_step | | elastictranscoder | pipeline | `arn:{partition}:elastictranscoder:{region}:{account}:pipeline/{resource_id}` | PipelineId | `[0-9a-zA-Z-_]{1,255}` | | AWS::ElasticTranscoder::Pipeline | aws_elastictranscoder_pipeline | | elastictranscoder | preset | `arn:{partition}:elastictranscoder:{region}:{account}:preset/{resource_id}` | PresetId | `[0-9a-zA-Z-_]{1,255}` | | AWS::ElasticTranscoder::Preset | aws_elastictranscoder_preset | -| es | domain | `arn:{partition}:es:{region}:{account}:domain/{resource_id}` | DomainName | `[a-z0-9][a-z0-9-]{2,28}[a-z0-9]` | AwsElasticSearchDomain | AWS::Elasticsearch::Domain | aws_elasticsearch_domain | +| es | domain | `arn:{partition}:es:{region}:{account}:domain/{resource_id}` | DomainName | `[a-z0-9][a-z0-9-]{2,28}[a-z0-9]` | AwsElasticsearchDomain | AWS::Elasticsearch::Domain | aws_elasticsearch_domain | | events | archive | `arn:{partition}:events:{region}:{account}:archive/{resource_id}` | ArchiveName | `[0-9a-zA-Z_.:-]+` | | AWS::Events::Archive | aws_cloudwatch_event_archive | | events | bus | `arn:{partition}:events:{region}:{account}:event-bus/{resource_id}` | EventBusName | `[0-9a-zA-Z_]+` | | AWS::Events::EventBus | aws_cloudwatch_event_bus | | events | rule | `arn:{partition}:events:{region}:{account}:rule/{resource_id}` | RuleName | `[0-9a-zA-Z_]+` | | AWS::Events::Rule | aws_cloudwatch_event_rule | diff --git a/aws_arn/__init__.py b/aws_arn/__init__.py index 695ad2b..ed87251 100644 --- a/aws_arn/__init__.py +++ b/aws_arn/__init__.py @@ -158,6 +158,14 @@ def parse_arn(arn): def get_service_from_arn(arn): service_from_arn = arn.split(":")[2] + # Fix service for elasticloadbalancing: + if service_from_arn == "elasticloadbalancing": + if "/app/" in arn: + service_from_arn = "elbv2" + elif "/net/" in arn: + service_from_arn = "elbv2" + else: + service_from_arn = "elb" try: service = aws_arn_data[service_from_arn] return service_from_arn @@ -196,6 +204,11 @@ def get_sub_service_from_arn(arn): return "topic" else: return "subscription" + elif service == "elbv2": + if "/app/" in arn: + return "app_loadbalancer" + elif "/net/" in arn: + return "net_loadbalancer" elif arn_part_5.startswith("/"): sub_service_from_arn = arn.split(":")[5].split("/")[1].replace("-", "_") else: diff --git a/aws_arn/data.py b/aws_arn/data.py index a4a02b3..19958ac 100644 --- a/aws_arn/data.py +++ b/aws_arn/data.py @@ -1452,8 +1452,16 @@ }, }, "elbv2": { - "loadbalancer": { - "arn_format": "arn:{partition}:elasticloadbalancing:{region}:{account}:loadbalancer/{resource_id}", + "app_loadbalancer": { + "arn_format": "arn:{partition}:elasticloadbalancing:{region}:{account}:loadbalancer/app/{resource_id}/{load_balancer_id}", + "id_name": "LoadBalancerName", + "id_regexp": "[\\w.-]{1,32}", + "asff_name": "AwsElbv2LoadBalancer", + "cloudformation": "AWS::ElasticLoadBalancingV2::LoadBalancer", + "terraform": "aws_alb", + }, + "net_loadbalancer": { + "arn_format": "arn:{partition}:elasticloadbalancing:{region}:{account}:loadbalancer/net/{resource_id}/{load_balancer_id}", "id_name": "LoadBalancerName", "id_regexp": "[\\w.-]{1,32}", "asff_name": "AwsElbv2LoadBalancer", diff --git a/setup.py b/setup.py index 0184e19..1c12fe9 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="aws-arn", - version="0.0.18", + version="0.0.19", description="A library to work with AWS ARNs", long_description=open("README.md").read(), long_description_content_type="text/markdown",