
    Vh                     "    d dl Z 	 ddZd Zd Zy)    Nc                 b   t        |       }|sy|r|j                  d      |k7  ry|r|j                  d      |k7  ry|r|j                  d      |k7  ry|r|j                  d      |k7  ry|r|j                  d      |k7  ry|r|j                  d      |k7  ry|r|j                  d      |k7  ryy	)
NF	partitionserviceregion
account_idresourceresource_typeresource_idT)parse_aws_arnget)	arnr   r   r   r   r   r	   r
   detailss	            g/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/amazon/aws/plugins/module_utils/arn.pyvalidate_aws_arnr   	   s     C GW[[-:7;;y)W4'++h'61gkk,/:=GKK
+x7_5Fw{{=1[@    c                    t        j                  d|       }|yt               }|j                  t        |j	                  d                   |j                  t        |j	                  d                   |j                  t        |j	                  d                   |j                  t        |j	                  d	      
             |j                  t        |j	                  d                   t        j                  d|j	                  d            }|-|j                  t        d|j	                  d                   |S |j                  t        |j	                  d      |j	                  d                   |S )a  
    Based on https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html

    The following are the general formats for ARNs.
        arn:partition:service:region:account-id:resource-id
        arn:partition:service:region:account-id:resource-type/resource-id
        arn:partition:service:region:account-id:resource-type:resource-id
    The specific formats depend on the resource.
    The ARNs for some resources omit the Region, the account ID, or both the Region and the account ID.

    Note: resource_type handling is very naive, for complex cases it may be necessary to use
    "resource" directly instead of resource_type, this will include the resource type and full ID,
    including all paths.
    zIarn:(aws(-([a-z\-]+))?):([\w-]+):([a-z0-9\-]*):(\d*|aws|aws-managed):(.*)N   )r      )r      )r      )r      )r   z^(.*?)[:/](.+)$)r	   r
      )researchdictupdategroup)r   mresultm2s       r   r   r   #   s    			^`cdAyVF
MM$,-
MM$qwwqz*+
MM$aggaj)*
MM$!''!*-.
MM$
+,	%qwwqz	2B	zd1771:FG M 	d!"((1+NOMr   c                     t        |       }|sy|j                  d      xs d}|j                         dk7  ry|j                  d      xs d}t        j                  d|      syy)z
    Validates that the ARN is for an AWS Outpost


    API Specification Document:
    https://docs.aws.amazon.com/outposts/latest/APIReference/API_Outpost.html
    Fr    outpostsr   z^outpost/op-[a-f0-9]{17}$T)r   r   lowerr   match)r   r   r   r   s       r   is_outpost_arnr&   G   s`     C Gkk)$*G}}*${{:&,"H88/:r   )NNNNNNN)r   r   r   r&    r   r   <module>r(      s!    
 uy4Hr   