diff --git a/providers/aws/resources/aws.lr b/providers/aws/resources/aws.lr index 7836fe78c9..221b1ae6af 100644 --- a/providers/aws/resources/aws.lr +++ b/providers/aws/resources/aws.lr @@ -977,6 +977,8 @@ private aws.s3.bucket @defaults("arn") { publicAccessBlock() dict // False if the bucket no longer exists (stale reference) exists bool + // Date the bucket was created + creationDate time } // Amazon S3 Bucket Grant @@ -1229,7 +1231,6 @@ private aws.rds.dbinstance @defaults("arn") { autoMinorVersionUpgrade bool } - // Amazon ElastiCache aws.elasticache { // Deprecated. Use `cacheClusters` instead. diff --git a/providers/aws/resources/aws.lr.go b/providers/aws/resources/aws.lr.go index c115b9ef8f..830272a640 100644 --- a/providers/aws/resources/aws.lr.go +++ b/providers/aws/resources/aws.lr.go @@ -1599,6 +1599,9 @@ var getDataFields = map[string]func(r plugin.Resource) *plugin.DataRes{ "aws.s3.bucket.exists": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlAwsS3Bucket).GetExists()).ToDataRes(types.Bool) }, + "aws.s3.bucket.creationDate": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlAwsS3Bucket).GetCreationDate()).ToDataRes(types.Time) + }, "aws.s3.bucket.grant.id": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlAwsS3BucketGrant).GetId()).ToDataRes(types.String) }, @@ -4215,6 +4218,10 @@ var setDataFields = map[string]func(r plugin.Resource, v *llx.RawData) bool { r.(*mqlAwsS3Bucket).Exists, ok = plugin.RawToTValue[bool](v.Value, v.Error) return }, + "aws.s3.bucket.creationDate": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlAwsS3Bucket).CreationDate, ok = plugin.RawToTValue[*time.Time](v.Value, v.Error) + return + }, "aws.s3.bucket.grant.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { r.(*mqlAwsS3BucketGrant).__id, ok = v.Value.(string) return @@ -11073,6 +11080,7 @@ type mqlAwsS3Bucket struct { Encryption plugin.TValue[interface{}] PublicAccessBlock plugin.TValue[interface{}] Exists plugin.TValue[bool] + CreationDate plugin.TValue[*time.Time] } // createAwsS3Bucket creates a new instance of this resource @@ -11238,6 +11246,10 @@ func (c *mqlAwsS3Bucket) GetExists() *plugin.TValue[bool] { return &c.Exists } +func (c *mqlAwsS3Bucket) GetCreationDate() *plugin.TValue[*time.Time] { + return &c.CreationDate +} + // mqlAwsS3BucketGrant for the aws.s3.bucket.grant resource type mqlAwsS3BucketGrant struct { MqlRuntime *plugin.Runtime diff --git a/providers/aws/resources/aws.lr.manifest.yaml b/providers/aws/resources/aws.lr.manifest.yaml index a649c4bb0b..61c581fc30 100755 --- a/providers/aws/resources/aws.lr.manifest.yaml +++ b/providers/aws/resources/aws.lr.manifest.yaml @@ -1957,6 +1957,8 @@ resources: acl: {} arn: {} cors: {} + creationDate: + min_mondoo_version: 9.0.0 defaultLock: {} encryption: {} exists: {} diff --git a/providers/aws/resources/aws_s3.go b/providers/aws/resources/aws_s3.go index 010802ab81..9314484ed7 100644 --- a/providers/aws/resources/aws_s3.go +++ b/providers/aws/resources/aws_s3.go @@ -83,10 +83,11 @@ func (a *mqlAwsS3) buckets() ([]interface{}, error) { } mqlS3Bucket, err := CreateResource(a.MqlRuntime, "aws.s3.bucket", map[string]*llx.RawData{ - "name": llx.StringData(convert.ToString(bucket.Name)), - "arn": llx.StringData(fmt.Sprintf(s3ArnPattern, convert.ToString(bucket.Name))), - "exists": llx.BoolData(true), - "location": llx.StringData(region), + "name": llx.StringData(convert.ToString(bucket.Name)), + "arn": llx.StringData(fmt.Sprintf(s3ArnPattern, convert.ToString(bucket.Name))), + "exists": llx.BoolData(true), + "location": llx.StringData(region), + "creationDate": llx.TimeData(toTime(bucket.CreationDate)), }) if err != nil { return nil, err