-
Notifications
You must be signed in to change notification settings - Fork 110
Add aws_ses_template table #2480
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f02c64e
Add aws_ses_template table
misraved 9ff8988
Improve the table docs
misraved 8b2d80e
Merge branch 'main' of github.com:turbot/steampipe-plugin-aws into ad…
misraved 0d12203
Update table as per review comments
misraved 5303b97
Added the ignore config'
misraved 9fe88f2
Fix panic error
misraved cb1c29d
Replaced the Get config with a hydrate config
misraved 44d1221
Remove the akas column and optimized the API call
misraved 2aefe78
Update aws/table_aws_ses_template.go
misraved 74b9724
Removed unnecessary transform function
ParthaI File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
package aws | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/aws/aws-sdk-go-v2/service/ses" | ||
"github.com/aws/aws-sdk-go-v2/service/ses/types" | ||
|
||
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto" | ||
"github.com/turbot/steampipe-plugin-sdk/v5/plugin" | ||
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform" | ||
) | ||
|
||
func tableAwsSESTemplate(_ context.Context) *plugin.Table { | ||
return &plugin.Table{ | ||
Name: "aws_ses_template", | ||
Description: "AWS SES Template", | ||
List: &plugin.ListConfig{ | ||
Hydrate: listSESTemplates, | ||
KeyColumns: []*plugin.KeyColumn{ | ||
{ | ||
Name: "name", | ||
Require: plugin.Optional, | ||
}, | ||
}, | ||
Tags: map[string]string{"service": "ses", "action": "ListTemplates"}, | ||
}, | ||
HydrateConfig: []plugin.HydrateConfig{ | ||
{ | ||
Func: getSESTemplateDetails, | ||
Tags: map[string]string{"service": "ses", "action": "GetTemplate"}, | ||
}, | ||
}, | ||
misraved marked this conversation as resolved.
Show resolved
Hide resolved
|
||
GetMatrixItemFunc: SupportedRegionMatrix(AWS_EMAIL_SERVICE_ID), | ||
Columns: awsRegionalColumns([]*plugin.Column{ | ||
{ | ||
Name: "name", | ||
Description: "The name of the template.", | ||
Type: proto.ColumnType_STRING, | ||
}, | ||
{ | ||
Name: "subject_part", | ||
Description: "The subject line of the email.", | ||
Type: proto.ColumnType_STRING, | ||
Hydrate: getSESTemplateDetails, | ||
}, | ||
{ | ||
Name: "text_part", | ||
Description: "The email body that will be visible to recipients whose email clients do not display HTML.", | ||
Type: proto.ColumnType_STRING, | ||
Hydrate: getSESTemplateDetails, | ||
}, | ||
{ | ||
Name: "html_part", | ||
Description: "The HTML body of the email.", | ||
Type: proto.ColumnType_STRING, | ||
Hydrate: getSESTemplateDetails, | ||
}, | ||
{ | ||
Name: "created_timestamp", | ||
Description: "The time and date the template was created.", | ||
Type: proto.ColumnType_TIMESTAMP, | ||
}, | ||
|
||
// Standard columns for all tables | ||
{ | ||
Name: "title", | ||
Description: resourceInterfaceDescription("title"), | ||
Type: proto.ColumnType_STRING, | ||
Transform: transform.FromField("Name"), | ||
}, | ||
}), | ||
} | ||
} | ||
|
||
//// LIST FUNCTION | ||
|
||
func listSESTemplates(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { | ||
// Create Session | ||
svc, err := SESClient(ctx, d) | ||
if err != nil { | ||
plugin.Logger(ctx).Error("aws_ses_template.listSESTemplates", "connection_error", err) | ||
return nil, err | ||
} | ||
if svc == nil { | ||
// Unsupported region check | ||
return nil, nil | ||
} | ||
|
||
maxItems := int32(1000) | ||
// Limiting the results | ||
if d.QueryContext.Limit != nil { | ||
limit := int32(*d.QueryContext.Limit) | ||
if limit < maxItems { | ||
maxItems = limit | ||
} | ||
} | ||
|
||
input := &ses.ListTemplatesInput{ | ||
MaxItems: &maxItems, | ||
} | ||
|
||
// List call | ||
output, err := svc.ListTemplates(ctx, input) | ||
if err != nil { | ||
plugin.Logger(ctx).Error("aws_ses_template.listSESTemplates", "api_error", err) | ||
return nil, err | ||
} | ||
|
||
for _, template := range output.TemplatesMetadata { | ||
d.StreamListItem(ctx, template) | ||
|
||
// Context can be cancelled due to manual cancellation or the limit has been hit | ||
if d.RowsRemaining(ctx) == 0 { | ||
return nil, nil | ||
} | ||
} | ||
|
||
return nil, nil | ||
} | ||
|
||
//// HYDRATE FUNCTIONS | ||
|
||
func getSESTemplateDetails(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { | ||
templateName := h.Item.(types.TemplateMetadata).Name | ||
|
||
misraved marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if templateName == nil { | ||
return nil, nil | ||
} | ||
if d.EqualsQualString("name") != "" && *templateName != d.EqualsQualString("name") { | ||
return nil, nil | ||
} | ||
|
||
svc, err := SESClient(ctx, d) | ||
if err != nil { | ||
plugin.Logger(ctx).Error("aws_ses_template.getSESTemplateDetails", "connection_error", err) | ||
return nil, err | ||
} | ||
if svc == nil { | ||
return nil, nil | ||
} | ||
|
||
params := &ses.GetTemplateInput{ | ||
TemplateName: templateName, | ||
} | ||
|
||
op, err := svc.GetTemplate(ctx, params) | ||
if err != nil { | ||
plugin.Logger(ctx).Error("aws_ses_template.getSESTemplateDetails", "api_error", err) | ||
return nil, err | ||
} | ||
|
||
return op.Template, nil | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
--- | ||
title: "Steampipe Table: aws_ses_template - Query AWS SES Templates using SQL" | ||
description: "Allows users to query AWS SES Templates and retrieve detailed information about each template, including its name, subject, content, and timestamps." | ||
folder: "SES" | ||
--- | ||
|
||
# Table: aws_ses_template - Query AWS SES Templates using SQL | ||
|
||
The AWS SES Template is a feature of Amazon Simple Email Service (SES) that allows you to create and manage email templates. These templates can include both HTML and text content, along with variables that can be replaced with actual values when sending emails. Templates help maintain consistent branding and messaging across your email communications while simplifying the email sending process. | ||
|
||
## Table Usage Guide | ||
|
||
The `aws_ses_template` table in Steampipe provides you with information about email templates within AWS Simple Email Service (SES). This table allows you, as a DevOps engineer or email administrator, to query template-specific details, including the template name, subject line, HTML and text content, and creation timestamp. You can utilize this table to gather insights on your email templates, such as their content, creation dates, and usage patterns. The schema outlines the various attributes of the SES template for you, including the template name, subject part, text part, HTML part, and associated metadata. | ||
|
||
## Examples | ||
|
||
### Basic info | ||
Explore the basic information of your AWS SES templates, including their names, subjects, and creation timestamps. This can help you maintain an overview of your email templates and their metadata. | ||
|
||
```sql+postgres | ||
select | ||
name, | ||
subject_part, | ||
created_timestamp | ||
from | ||
aws_ses_template; | ||
``` | ||
|
||
```sql+sqlite | ||
select | ||
name, | ||
subject_part, | ||
created_timestamp | ||
from | ||
aws_ses_template; | ||
``` | ||
|
||
### Get template details by name | ||
Retrieve detailed information about a specific template, including its subject line and content. This is useful for reviewing or updating specific templates. | ||
|
||
```sql+postgres | ||
select | ||
name, | ||
subject_part, | ||
text_part, | ||
html_part, | ||
created_timestamp | ||
from | ||
aws_ses_template | ||
where | ||
name = 'MyTemplate'; | ||
``` | ||
|
||
```sql+sqlite | ||
select | ||
name, | ||
subject_part, | ||
text_part, | ||
html_part, | ||
created_timestamp | ||
from | ||
aws_ses_template | ||
where | ||
name = 'MyTemplate'; | ||
``` | ||
|
||
### List templates created in the last 30 days | ||
Identify recently created templates to track new additions to your email template library. This can help in maintaining an up-to-date inventory of your email templates. | ||
|
||
```sql+postgres | ||
select | ||
name, | ||
subject_part, | ||
created_timestamp | ||
from | ||
aws_ses_template | ||
where | ||
created_timestamp >= now() - interval '30 days' | ||
order by | ||
created_timestamp desc; | ||
``` | ||
|
||
```sql+sqlite | ||
select | ||
name, | ||
subject_part, | ||
created_timestamp | ||
from | ||
aws_ses_template | ||
where | ||
created_timestamp >= datetime('now', '-30 days') | ||
order by | ||
created_timestamp desc; | ||
``` | ||
|
||
### List templates with HTML content | ||
Find templates that include HTML formatting, which is useful for identifying templates that require special rendering or may need additional testing across different email clients. | ||
|
||
```sql+postgres | ||
select | ||
name, | ||
subject_part, | ||
html_part | ||
from | ||
aws_ses_template | ||
where | ||
html_part is not null; | ||
``` | ||
|
||
```sql+sqlite | ||
select | ||
name, | ||
subject_part, | ||
html_part | ||
from | ||
aws_ses_template | ||
where | ||
html_part is not null; | ||
``` | ||
|
||
### List templates with text-only content | ||
Identify templates that contain only plain text content, which can be useful for ensuring accessibility and compatibility with all email clients. | ||
|
||
```sql+postgres | ||
select | ||
name, | ||
subject_part, | ||
text_part | ||
from | ||
aws_ses_template | ||
where | ||
html_part is null | ||
and text_part is not null; | ||
``` | ||
|
||
```sql+sqlite | ||
select | ||
name, | ||
subject_part, | ||
text_part | ||
from | ||
aws_ses_template | ||
where | ||
html_part is null | ||
and text_part is not null; | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.