[Bps-public-commit] rt-extension-aws-assets branch sync-utility updated. 9501e28e6a6762ca41fc827176e9cfa7491d7947

BPS Git Server git at git.bestpractical.com
Fri Feb 16 21:10:21 UTC 2024


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt-extension-aws-assets".

The branch, sync-utility has been updated
       via  9501e28e6a6762ca41fc827176e9cfa7491d7947 (commit)
       via  f6dd3c1717dfa88b79ac9e3a0c3e118a57e288be (commit)
      from  2e43ca30bb94c04ea71287d19567fbb5451896df (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 9501e28e6a6762ca41fc827176e9cfa7491d7947
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Feb 16 16:10:14 2024 -0500

    Add some sample initialdata

diff --git a/etc/sample-initialdata.json b/etc/sample-initialdata.json
new file mode 100644
index 0000000..455d9d5
--- /dev/null
+++ b/etc/sample-initialdata.json
@@ -0,0 +1,339 @@
+{
+   "Attributes" : [
+      {
+         "Content" : {
+            "Format" : "'<a href=\"__WebPath__/Asset/Display.html?id=__id__\">__id__</a>/TITLE:#',\n'<a href=\"__WebHomePath__/Asset/Display.html?id=__id__\">__Name__</a>/TITLE:Name',\nStatus,\nCatalog,\nOwner,\n'__ActiveTickets__ __InactiveTickets__/TITLE:Related tickets',\n'__NEWLINE__',\n'__NBSP__',\n'<small>__Description__</small>',\n'<small>__CreatedRelative__</small>',\n'<small>__LastUpdatedRelative__</small>',\n'<small>__Contacts__</small>'",
+            "ObjectType" : "",
+            "Order" : "ASC|ASC|ASC|ASC",
+            "OrderBy" : "Name|||",
+            "Query" : "Catalog = 'AWS Resources' AND Status = '__Active__'",
+            "RowsPerPage" : "50",
+            "SearchType" : "Asset"
+         },
+         "ContentType" : "storable",
+         "Description" : "Active Assets",
+         "Name" : "SavedSearch",
+         "Object" : "RT::System"
+      },
+      {
+         "Content" : {},
+         "ContentType" : "storable",
+         "Name" : "CustomFieldDefaultValues",
+         "Object" : "RT::System"
+      },
+      {
+         "Content" : {
+            "Due" : "in 3 days",
+            "FinalPriority" : "0",
+            "InitialPriority" : "0"
+         },
+         "ContentType" : "storable",
+         "Name" : "DefaultValues",
+         "Object" : "General",
+         "ObjectType" : "RT::Queue"
+      },
+      {
+         "Content" : {
+            "Format" : "'<a href=\"__WebPath__/Asset/Display.html?id=__id__\">__id__</a>/TITLE:#',\n'<a href=\"__WebHomePath__/Asset/Display.html?id=__id__\">__Name__</a>/TITLE:Name',\nCatalog,\n'__CustomFieldView.{Region}__',\n'__CustomFieldView.{Instance Type}__',\n'__CustomFieldView.{Reservation Start}__',\n'__CustomFieldView.{Reservation End}__',\n'__CustomFieldView.{Service Type}__',\n'__CustomFieldView.{Product Description}__',\n'<a href=\"__WebPath__/AWS/LinkAsset.html?id=__id__\" target=\"_blank\">Link to Resource</a>/TITLE:Link to Resource'",
+            "ObjectType" : "",
+            "Order" : "ASC|ASC|ASC|ASC",
+            "OrderBy" : "CustomField.{Service Type}|||",
+            "Query" : "Catalog = 'AWS Reserved Instances' AND DependedOnBy IS NULL AND CF.{State} = 'active'",
+            "RowsPerPage" : "50",
+            "SearchType" : "Asset"
+         },
+         "ContentType" : "storable",
+         "Description" : "Unlinked AWS Reservations",
+         "Name" : "SavedSearch",
+         "Object" : "RT::System"
+      }
+   ],
+   "Catalogs" : [
+      {
+         "Description" : "AWS Resources",
+         "Lifecycle" : "assets",
+         "Name" : "AWS Resources"
+      },
+      {
+         "Description" : "",
+         "Lifecycle" : "assets",
+         "Name" : "AWS Reserved Instances"
+      }
+   ],
+   "CustomFields" : [
+      {
+         "ApplyTo" : [
+            "AWS Resources"
+         ],
+         "Description" : "The AWS generated ID for this resource",
+         "EntryHint" : "ID assigned in AWS",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "AWS ID",
+         "SortOrder" : 0,
+         "Type" : "Freeform",
+         "UniqueValues" : 1
+      },
+      {
+         "ApplyTo" : [
+            "AWS Reserved Instances",
+            "AWS Resources"
+         ],
+         "Description" : "",
+         "EntryHint" : "Select one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "Service Type",
+         "SortOrder" : 0,
+         "Type" : "Select",
+         "Values" : [
+            {
+               "Name" : "EC2",
+               "SortOrder" : 0
+            },
+            {
+               "Name" : "Open Search",
+               "SortOrder" : 0
+            },
+            {
+               "Name" : "RDS",
+               "SortOrder" : 0
+            }
+         ]
+      },
+      {
+         "ApplyTo" : [
+            "AWS Reserved Instances",
+            "AWS Resources"
+         ],
+         "Description" : "",
+         "EntryHint" : "Enter one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "Instance Type",
+         "SortOrder" : 0,
+         "Type" : "Freeform"
+      },
+      {
+         "ApplyTo" : [
+            "AWS Reserved Instances",
+            "AWS Resources"
+         ],
+         "Description" : "",
+         "EntryHint" : "Enter one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "Platform",
+         "SortOrder" : 0,
+         "Type" : "Freeform"
+      },
+      {
+         "ApplyTo" : [
+            "AWS Reserved Instances",
+            "AWS Resources"
+         ],
+         "Description" : "",
+         "EntryHint" : "Enter one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "Tenancy",
+         "SortOrder" : 0,
+         "Type" : "Freeform"
+      },
+      {
+         "ApplyTo" : [
+            "AWS Reserved Instances",
+            "AWS Resources"
+         ],
+         "Description" : "",
+         "EntryHint" : "Enter one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "Region",
+         "SortOrder" : 0,
+         "Type" : "Freeform"
+      },
+      {
+         "ApplyTo" : [
+            "AWS Resources"
+         ],
+         "Description" : "",
+         "EntryHint" : "Enter one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "Availability Zone",
+         "SortOrder" : 0,
+         "Type" : "Freeform"
+      },
+      {
+         "ApplyTo" : [
+            "AWS Resources"
+         ],
+         "Description" : "",
+         "EntryHint" : "Enter one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "customer",
+         "SortOrder" : 0,
+         "Type" : "Freeform"
+      },
+      {
+         "ApplyTo" : [
+            "AWS Resources"
+         ],
+         "Description" : "",
+         "EntryHint" : "Enter one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "Engine",
+         "SortOrder" : 0,
+         "Type" : "Freeform"
+      },
+      {
+         "ApplyTo" : [
+            "AWS Resources"
+         ],
+         "Description" : "",
+         "EntryHint" : "Enter one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "Allocated Storage",
+         "SortOrder" : 0,
+         "Type" : "Freeform"
+      },
+      {
+         "ApplyTo" : [
+            "AWS Reserved Instances"
+         ],
+         "Description" : "",
+         "EntryHint" : "Select date",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "Reservation Start",
+         "SortOrder" : 0,
+         "Type" : "Date"
+      },
+      {
+         "ApplyTo" : [
+            "AWS Reserved Instances"
+         ],
+         "Description" : "",
+         "EntryHint" : "Select date",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "Reservation End",
+         "SortOrder" : 0,
+         "Type" : "Date"
+      },
+      {
+         "ApplyTo" : [
+            "AWS Reserved Instances"
+         ],
+         "Description" : "",
+         "EntryHint" : "Enter one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "Duration",
+         "SortOrder" : 0,
+         "Type" : "Freeform"
+      },
+      {
+         "ApplyTo" : [
+            "AWS Reserved Instances"
+         ],
+         "Description" : "",
+         "EntryHint" : "Enter one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "Offering Class",
+         "SortOrder" : 0,
+         "Type" : "Freeform"
+      },
+      {
+         "ApplyTo" : [
+            "AWS Reserved Instances"
+         ],
+         "Description" : "",
+         "EntryHint" : "Enter one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "Offering Type",
+         "SortOrder" : 0,
+         "Type" : "Freeform"
+      },
+      {
+         "ApplyTo" : [
+            "AWS Reserved Instances"
+         ],
+         "Description" : "",
+         "EntryHint" : "Select one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "MultiAZ",
+         "RenderType" : "Checkbox",
+         "SortOrder" : 0,
+         "Type" : "Select",
+         "Values" : [
+            {
+               "Name" : "0",
+               "SortOrder" : 0
+            },
+            {
+               "Name" : "1",
+               "SortOrder" : 0
+            }
+         ]
+      },
+      {
+         "ApplyTo" : [
+            "AWS Reserved Instances"
+         ],
+         "Description" : "",
+         "EntryHint" : "Enter one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "AWS Reserved Instance ID",
+         "SortOrder" : 0,
+         "Type" : "Freeform"
+      },
+      {
+         "ApplyTo" : [
+            "AWS Reserved Instances"
+         ],
+         "Description" : "",
+         "EntryHint" : "Enter one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "Product Description",
+         "SortOrder" : 0,
+         "Type" : "Freeform"
+      },
+      {
+         "ApplyTo" : [
+            "AWS Reserved Instances"
+         ],
+         "Description" : "",
+         "EntryHint" : "Enter one value",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 1,
+         "Name" : "State",
+         "SortOrder" : 0,
+         "Type" : "Freeform"
+      }
+   ],
+   "CustomRoles" : [
+      {
+         "Description" : "",
+         "EntryHint" : "",
+         "LookupType" : "RT::Catalog-RT::Asset",
+         "MaxValues" : 0,
+         "Name" : "Customer"
+      }
+   ],
+   "Groups" : [
+      {
+         "Domain" : "UserDefined",
+         "Name" : "AWS Asset Users"
+      }
+   ]
+}
commit f6dd3c1717dfa88b79ac9e3a0c3e118a57e288be
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Feb 16 16:08:30 2024 -0500

    Add docs

diff --git a/README b/README
index 7843050..8031b4c 100644
--- a/README
+++ b/README
@@ -23,6 +23,94 @@ INSTALLATION
 
     Restart your webserver
 
+USAGE
+    This extension is designed to fetch data for EC2 and RDS instances in
+    AWS and create RT asset records for each. It also can fetch information
+    on reserved instances and create assets records for these, in a
+    different catalog.
+
+    Once you have fetched the above information, you can use linking in RT
+    to associate an AWS resource, like an AWS EC2 instance, with a
+    reservation you have purchased. The extension provides a page in the RT
+    web UI at https://myrt.com/AWS/LinkAsset.html?id=123 to match AWS
+    resources with reservations based on the service, instance type, and
+    region.
+
+CONFIGURATION
+    The following configuration options need to be set to use this
+    extension.
+
+  AWS API Credentials
+    In the AWS IAM console, create keys for external access and set:
+
+        Set($AWS_ACCESS_KEY, 'foo');
+        Set($AWS_SECRET_KEY, 'barbaz');
+
+  Asset Catalogs
+    Set the following with the names of the catalogs to use for AWS
+    resources (like EC2 and RDS instances) and reserved instances.
+
+        Set($AWSAssetsInstanceCatalog, 'AWS Resources');
+        Set($AWSAssetsReservedInstancesCatalog, 'AWS Reserved Instances');
+
+  Data Field Mapping
+    Information from AWS resources is stored mostly in custom fields on
+    assets in RT. Use this configuration to define which custom fields to
+    populate. The names mostly map to the name provided by AWS in the API.
+
+    The EC2 and RDS keys are for AWS resources. The EC2:RI and RDS:RI are
+    for reserved instances.
+
+        Set($AWSAssetsUpdateFields, {
+            'EC2' => ['Instance Type', 'Platform', 'Placement:Tenancy', 'Placement:Availability Zone', 'Tags:Name', 'Tags:customer'],
+            'RDS' => ['Instance Type', 'Engine', 'Allocated Storage', 'Availability Zone', 'Name', 'MultiAZ', 'TagList:customer'],
+            'EC2:RI' => ['Instance Type', 'Platform', 'Tenancy', 'Reservation Start', 'Reservation End', 'Duration', 'Offering Class', 'Offering Type', 'Name', 'Product Description', 'State'],
+            'RDS:RI' => ['Instance Type', 'Platform', 'Reservation Start', 'Reservation End', 'Duration', 'Offering Type', 'Name', 'MultiAZ', 'Product Description', 'State'],
+        }
+        );
+
+  Asset Linking Page
+    This format defines the columns shown on the reservation linking page.
+
+    Set($AWSAssetsLinkFormat, q{'<a
+    href="__WebPath__/Asset/Display.html?id=__id__">__id__</a>/TITLE:#'}
+    .q{,'<a
+    href="__WebHomePath__/Asset/Display.html?id=__id__">__Name__</a>/TITLE:N
+    ame'} .q{,'__CustomFieldView.{AWS ID}__'}
+    .q{,'__CustomFieldView.{customer}__'} .q{,'__CustomFieldView.{Instance
+    Type}__'} .q{,'__CustomFieldView.{Engine}__'} );
+
+    To link to this page, create a saved search to find any unlinked
+    reserved instance records. A search like this should find these records:
+
+        Catalog = 'AWS Reserved Instances' AND DependedOnBy IS NULL AND ( CF.{State} = 'payment-pending' OR CF.{State} = 'active' )
+
+    After creating the search, go to the Advanced page and add this line to
+    the Format:
+
+    '<a href="__WebPath__/AWS/LinkAsset.html?id=__id__" target="_blank">Link
+    to Resource</a>/TITLE:Link to Resource'
+
+    That will show a column linking to the reservation linking page.
+
+  AWS IDs Used for Assets
+    AWS uses different identifiers with different services. This extension
+    uses the below mapping of AWS value to RT custom fields on assets. When
+    a new asset is created, the named custom fields must exist and they will
+    be set. On update, this value is used to load new data from the existing
+    assets.
+
+    EC2 AWS Value: "Instance ID" RT Asset CF: "AWS ID"
+
+    RDS AWS Value: "DBI Resource ID" RT Asset CF: "AWS ID"
+
+    EC2 Reserved Instance
+        AWS Value: "Reserved Instances ID" RT Asset CF: "AWS Reserved
+        Instance ID"
+
+    RDS Reserved Instance
+        AWS Value: "Lease ID" RT Asset CF: "AWS Reserved Instance ID"
+
 METHODS
     Accept a loaded RT::Asset object and a Paws Instance object.
 
diff --git a/bin/rt-import-aws-assets.in b/bin/rt-import-aws-assets.in
index 9f3e5cc..6e060b2 100644
--- a/bin/rt-import-aws-assets.in
+++ b/bin/rt-import-aws-assets.in
@@ -74,7 +74,7 @@ sub process_args {
     local @ARGV = @_;
 
     my %opt;
-    RT::Interface::CLI::Init( \%opt, 'help|h', 'insert|i', 'update|u', 'catalog=s', 'type=s', 'reserved', 'region=s', 'results=i', 'debug|d' );
+    RT::Interface::CLI::Init( \%opt, 'help|h', 'insert|i', 'update|u', 'type=s', 'reserved', 'region=s', 'results=i', 'debug|d' );
 
     if ( delete $opt{help} ) {
         require Pod::Usage;
@@ -104,10 +104,53 @@ rt-import-aws-assets - import asset data from AWS
 
 =head1 SYNOPSIS
 
-    rt-import-aws-assets
+    rt-import-aws-assets --region='us-east-1' --type=EC2 --insert
 
 =head1 DESCRIPTION
 
-Access your AWS account using the aws-cli utility to pull in data and
-add it to RT assets.
+This utility pulls data from the configured AWS account and inserts
+or updates asset records in Request Tracker.
 
+See the main extension documentation for key configuration options
+including the asset catalogs to use.
+
+=head1 OPTIONS
+
+=over
+
+=item B<--region>
+
+Required. The region from which to pull AWS resource information.
+
+=item B<--type>
+
+Required. The AWS service to use when fetching information.
+
+Currently supported: EC2, RDS
+
+=item B<--insert>
+
+When fetching records, create new records for any resources that don't
+exist. Existing records are skipped.
+
+=item B<--update>
+
+Search for existing assets and update configured fields from AWS data.
+
+=item B<--reserved>
+
+Retrieve data for reserved instances for the current C<--type>.
+
+=item B<--results>
+
+The number of results to fetch per request to the AWS API. The minimum is 20,
+maximum is 100. Some AWS APIs do not support paging so this is ignored.
+
+=item B<--debug>
+
+Override the RT log settings and show log messages in the terminal at the
+debug level.
+
+=back
+
+=cut
diff --git a/lib/RT/Extension/AWS/Assets.pm b/lib/RT/Extension/AWS/Assets.pm
index 4f6cedf..6702f3a 100644
--- a/lib/RT/Extension/AWS/Assets.pm
+++ b/lib/RT/Extension/AWS/Assets.pm
@@ -47,6 +47,112 @@ Add this line:
 
 =back
 
+=head1 USAGE
+
+This extension is designed to fetch data for EC2 and RDS instances in
+AWS and create RT asset records for each. It also can fetch information
+on reserved instances and create assets records for these, in a different
+catalog.
+
+Once you have fetched the above information, you can use linking in RT
+to associate an AWS resource, like an AWS EC2 instance, with a reservation
+you have purchased. The extension provides a page in the RT web UI at
+C<https://myrt.com/AWS/LinkAsset.html?id=123> to match AWS resources
+with reservations based on the service, instance type, and region.
+
+=head1 CONFIGURATION
+
+The following configuration options need to be set to use this
+extension.
+
+=head2 AWS API Credentials
+
+In the AWS IAM console, create keys for external access and set:
+
+    Set($AWS_ACCESS_KEY, 'foo');
+    Set($AWS_SECRET_KEY, 'barbaz');
+
+=head2 Asset Catalogs
+
+Set the following with the names of the catalogs to use for AWS
+resources (like EC2 and RDS instances) and reserved instances.
+
+    Set($AWSAssetsInstanceCatalog, 'AWS Resources');
+    Set($AWSAssetsReservedInstancesCatalog, 'AWS Reserved Instances');
+
+=head2 Data Field Mapping
+
+Information from AWS resources is stored mostly in custom fields on
+assets in RT. Use this configuration to define which custom fields to
+populate. The names mostly map to the name provided by AWS in the API.
+
+The EC2 and RDS keys are for AWS resources. The EC2:RI and RDS:RI are
+for reserved instances.
+
+    Set($AWSAssetsUpdateFields, {
+        'EC2' => ['Instance Type', 'Platform', 'Placement:Tenancy', 'Placement:Availability Zone', 'Tags:Name', 'Tags:customer'],
+        'RDS' => ['Instance Type', 'Engine', 'Allocated Storage', 'Availability Zone', 'Name', 'MultiAZ', 'TagList:customer'],
+        'EC2:RI' => ['Instance Type', 'Platform', 'Tenancy', 'Reservation Start', 'Reservation End', 'Duration', 'Offering Class', 'Offering Type', 'Name', 'Product Description', 'State'],
+        'RDS:RI' => ['Instance Type', 'Platform', 'Reservation Start', 'Reservation End', 'Duration', 'Offering Type', 'Name', 'MultiAZ', 'Product Description', 'State'],
+    }
+    );
+
+=head2 Asset Linking Page
+
+This format defines the columns shown on the reservation linking page.
+
+Set($AWSAssetsLinkFormat,
+    q{'<a href="__WebPath__/Asset/Display.html?id=__id__">__id__</a>/TITLE:#'}
+    .q{,'<a href="__WebHomePath__/Asset/Display.html?id=__id__">__Name__</a>/TITLE:Name'}
+    .q{,'__CustomFieldView.{AWS ID}__'}
+    .q{,'__CustomFieldView.{customer}__'}
+    .q{,'__CustomFieldView.{Instance Type}__'}
+    .q{,'__CustomFieldView.{Engine}__'}
+);
+
+To link to this page, create a saved search to find any unlinked reserved
+instance records. A search like this should find these records:
+
+    Catalog = 'AWS Reserved Instances' AND DependedOnBy IS NULL AND ( CF.{State} = 'payment-pending' OR CF.{State} = 'active' )
+
+After creating the search, go to the Advanced page and add this line to the Format:
+
+'<a href="__WebPath__/AWS/LinkAsset.html?id=__id__" target="_blank">Link to Resource</a>/TITLE:Link to Resource'
+
+That will show a column linking to the reservation linking page.
+
+=head2 AWS IDs Used for Assets
+
+AWS uses different identifiers with different services. This extension uses
+the below mapping of AWS value to RT custom fields on assets. When a
+new asset is created, the named custom fields must exist and they
+will be set. On update, this value is used to load new data from
+the existing assets.
+
+=over
+
+=item EC2
+
+AWS Value: "Instance ID"
+RT Asset CF: "AWS ID"
+
+=item RDS
+
+AWS Value: "DBI Resource ID"
+RT Asset CF: "AWS ID"
+
+=item EC2 Reserved Instance
+
+AWS Value: "Reserved Instances ID"
+RT Asset CF: "AWS Reserved Instance ID"
+
+=item RDS Reserved Instance
+
+AWS Value: "Lease ID"
+RT Asset CF: "AWS Reserved Instance ID"
+
+=back
+
 =head1 METHODS
 
 =cut
-----------------------------------------------------------------------

Summary of changes:
 README                         |  88 +++++++++++
 bin/rt-import-aws-assets.in    |  51 ++++++-
 etc/sample-initialdata.json    | 339 +++++++++++++++++++++++++++++++++++++++++
 lib/RT/Extension/AWS/Assets.pm | 106 +++++++++++++
 4 files changed, 580 insertions(+), 4 deletions(-)
 create mode 100644 etc/sample-initialdata.json


hooks/post-receive
-- 
rt-extension-aws-assets


More information about the Bps-public-commit mailing list