Skip to content

Commit

Permalink
⭐️ AWS TimeStream LifeAnalytics resources (#4532)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-rock authored Aug 12, 2024
1 parent bc8a5ac commit 2ffaac2
Show file tree
Hide file tree
Showing 8 changed files with 777 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ istio
jira
jsonbody
labelmatchstatement
lifeanalytics
loggingservice
managedrulegroupstatement
managedzone
Expand Down Expand Up @@ -91,6 +92,7 @@ sqlserver
targetgroup
tde
testutils
timestream
toplevel
tpu
vdcs
Expand Down
56 changes: 56 additions & 0 deletions providers/aws/connection/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ import (
"github.com/aws/aws-sdk-go-v2/service/sns"
"github.com/aws/aws-sdk-go-v2/service/sqs"
"github.com/aws/aws-sdk-go-v2/service/ssm"
"github.com/aws/aws-sdk-go-v2/service/timestreaminfluxdb"
"github.com/aws/aws-sdk-go-v2/service/timestreamwrite"
"github.com/aws/aws-sdk-go-v2/service/wafv2"
"github.com/rs/zerolog/log"
)
Expand Down Expand Up @@ -776,6 +778,60 @@ func (t *AwsConnection) Neptune(region string) *neptune.Client {
return client
}

// TimestreamLifeAnalytics returns a Timestream client for Life Analytics
func (t *AwsConnection) TimestreamLifeAnalytics(region string) *timestreamwrite.Client {
// if no region value is sent in, use the configured region
if len(region) == 0 {
region = t.cfg.Region
}
cacheVal := "_timestream_" + region

// check for cached client and return it if it exists
c, ok := t.clientcache.Load(cacheVal)
if ok {
log.Debug().Msg("use cached timestreamwrite client")
return c.Data.(*timestreamwrite.Client)
}

// create the client
cfg := t.cfg.Copy()
cfg.Region = region

// Create a Neptune client from just a session.
client := timestreamwrite.NewFromConfig(cfg)

// cache it
t.clientcache.Store(cacheVal, &CacheEntry{Data: client})
return client
}

// TimestreamInflux returns a Timestream client for InfluxDB
func (t *AwsConnection) TimestreamInfluxDB(region string) *timestreaminfluxdb.Client {
// if no region value is sent in, use the configured region
if len(region) == 0 {
region = t.cfg.Region
}
cacheVal := "_timestream_" + region

// check for cached client and return it if it exists
c, ok := t.clientcache.Load(cacheVal)
if ok {
log.Debug().Msg("use cached timestreaminfluxdb client")
return c.Data.(*timestreaminfluxdb.Client)
}

// create the client
cfg := t.cfg.Copy()
cfg.Region = region

// Create a Neptune client from just a session.
client := timestreaminfluxdb.NewFromConfig(cfg)

// cache it
t.clientcache.Store(cacheVal, &CacheEntry{Data: client})
return client
}

func (t *AwsConnection) AccessAnalyzer(region string) *accessanalyzer.Client {
// if no region value is sent in, use the configured region
if len(region) == 0 {
Expand Down
3 changes: 3 additions & 0 deletions providers/aws/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ require (
github.com/aws/aws-sdk-go-v2/service/sqs v1.34.3
github.com/aws/aws-sdk-go-v2/service/ssm v1.52.4
github.com/aws/aws-sdk-go-v2/service/sts v1.30.3
github.com/aws/aws-sdk-go-v2/service/timestreaminfluxdb v1.2.3
github.com/aws/aws-sdk-go-v2/service/timestreamwrite v1.27.3
github.com/aws/aws-sdk-go-v2/service/wafv2 v1.51.4
github.com/aws/smithy-go v1.20.3
github.com/cockroachdb/errors v1.11.3
Expand All @@ -63,6 +65,7 @@ require (
github.com/spf13/afero v1.11.0
github.com/stretchr/testify v1.9.0
go.mondoo.com/cnquery/v11 v11.16.1
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa
k8s.io/client-go v0.30.3
)

Expand Down
6 changes: 6 additions & 0 deletions providers/aws/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 h1:yiwVzJW2ZxZTurVbYWA7QOrA
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4/go.mod h1:0oxfLkpz3rQ/CHlx5hB7H69YUpFiI1tql6Q6Ne+1bCw=
github.com/aws/aws-sdk-go-v2/service/sts v1.30.3 h1:ZsDKRLXGWHk8WdtyYMoGNO7bTudrvuKpDKgMVRlepGE=
github.com/aws/aws-sdk-go-v2/service/sts v1.30.3/go.mod h1:zwySh8fpFyXp9yOr/KVzxOl8SRqgf/IDw5aUt9UKFcQ=
github.com/aws/aws-sdk-go-v2/service/timestreaminfluxdb v1.2.3 h1:Qbimk+9ZyMxjyunIkdvaDeA/LLbeSV0NqurwC2D/gKg=
github.com/aws/aws-sdk-go-v2/service/timestreaminfluxdb v1.2.3/go.mod h1:2AEQ9klGEJdMIg+bC1gnGGiJqKebIkhfwJyNYBYh9dg=
github.com/aws/aws-sdk-go-v2/service/timestreamwrite v1.27.3 h1:GbbpHIz5tBazjVOunsf6xcgruWFvj1DT+jUNyKDwK2s=
github.com/aws/aws-sdk-go-v2/service/timestreamwrite v1.27.3/go.mod h1:sXSJhu0vub083lif2S+g7fPocwVuqu9D9Bp1FEIYqOE=
github.com/aws/aws-sdk-go-v2/service/wafv2 v1.51.4 h1:1khBA5uryBRJoCb4G2iR5RT06BkfPEjjDCHAiRb8P3Q=
github.com/aws/aws-sdk-go-v2/service/wafv2 v1.51.4/go.mod h1:QpFImaPGKNwa+MiZ+oo6LbV1PVQBapc0CnrAMRScoxM=
github.com/aws/smithy-go v1.20.3 h1:ryHwveWzPV5BIof6fyDvor6V3iUL7nTfiTKXHiW05nE=
Expand Down Expand Up @@ -540,6 +544,8 @@ golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDf
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI=
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
Expand Down
48 changes: 47 additions & 1 deletion providers/aws/resources/aws.lr
Original file line number Diff line number Diff line change
Expand Up @@ -3428,4 +3428,50 @@ private aws.neptune.instance @defaults("arn name status"){
storageType string
// Key store with which the instance is associated for TDE encryption
tdeCredentialArn string
}
}

// Amazon Timestream for LifeAnalytics
aws.timestream.lifeanalytics @defaults("databases") {
// List of databases
databases() []aws.timestream.lifeanalytics.database
// List of database tables
tables() []aws.timestream.lifeanalytics.table
}

// Amazon Timestream for LifeAnalytics database
private aws.timestream.lifeanalytics.database @defaults("name region") {
// ARN for the database
arn string
// Name of the database
name string
// KMS key used to encrypt the data stored in the database
kmsKeyId string
// Region where the database exists
region string
// Time when the database was created
createdAt time
// Time when the database was last updated
updatedAt time
// Total number of tables in database
tableCount int
}

// Amazon Timestream for LifeAnalytics table
private aws.timestream.lifeanalytics.table @defaults("name region") {
// ARN for the table
arn string
// Name of the table
name string
// Name of the database
databaseName string
// Region where the table exists
region string
// Time when the table was created
createdAt time
// Time when the table was last updated
updatedAt time
// magnetic store properties for the table
magneticStoreWriteProperties dict
// retention duration properties for the table
retentionProperties dict
}
Loading

0 comments on commit 2ffaac2

Please sign in to comment.