skip to Main Content

I am try to find resources and their arn which were created by cdk automatically ( like IAM roles and policies as dependent resources)

I can see in the cloudformation physical id there is physical id but there is hyperlink to it like other resources plus I am not able to find those resources by their physical id in the console.

2

Answers


  1. Could you group the resources together by tagging them with a tag name in your CDK, and then you can find them by tag in the Console?

    One other possibility is to use CloudTrail, which shows history of events in your account. The creation of the new resources should show up in CloudTrail.

    Login or Signup to reply.
  2. I am not able to find those resources by their physical id in the console.

    I do not think AWS allows to search by arbitrary text and find proper resource associated with it.

    What you can do is print list of resources created by given stack

    aws cloudformation list-stack-resources --stack-name <YOUR_STACK_NAME_HERE> 
      | jq -r '.StackResourceSummaries[] | [.ResourceType, .PhysicalResourceId] | @tsv'
    

    and apply some post-processing to analyze ResourceType and create links for known types.

    For example, script below detects IAM roles and EMR clusters and prints links to such kind of resources

    aws cloudformation list-stack-resources --stack-name <YOUR_STACK_NAME_HERE> 
     | jq -r '.StackResourceSummaries[] | [.ResourceType, (
       if   .ResourceType == "AWS::IAM::Role" then "https://console.aws.amazon.com/iamv2/home#/roles/details/"+.PhysicalResourceId 
       elif .ResourceType == "AWS::EMR::Cluster" then "https://console.aws.amazon.com/elasticmapreduce/home#cluster-details:"+.PhysicalResourceId 
       else .PhysicalResourceId 
       end)] | @tsv'
    

    However, it will require continuous maintenance for this script when you start creating more and more different ResourceTypes


    Note, aws cloudformation has two similar commands – describe-stack-resources and list-stack-resources. Former is limited, quote from their documentation

    Note: Only the first 100 resources will be returned. If your stack has more resources than this, you should use ListStackResources instead.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search