Skip to content

Commit ff7c8ba

Browse files
afiunetas50
andauthored
✨ aws codedeploy resource (#5590)
* ✨ aws codedeploy resource Signed-off-by: Salim Afiune Maya <afiune@mondoo.com> * 🧹 rename time fields Signed-off-by: Salim Afiune Maya <afiune@mondoo.com> * 🧹 code reviews Co-authored-by: Tim Smith <tsmith84@gmail.com> --------- Signed-off-by: Salim Afiune Maya <afiune@mondoo.com> Co-authored-by: Tim Smith <tsmith84@gmail.com>
1 parent ed7fb87 commit ff7c8ba

7 files changed

Lines changed: 1626 additions & 0 deletions

File tree

providers/aws/connection/clients.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/aws/aws-sdk-go-v2/service/cloudwatch"
1919
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs"
2020
"github.com/aws/aws-sdk-go-v2/service/codebuild"
21+
"github.com/aws/aws-sdk-go-v2/service/codedeploy"
2122
"github.com/aws/aws-sdk-go-v2/service/configservice"
2223
"github.com/aws/aws-sdk-go-v2/service/databasemigrationservice"
2324
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
@@ -1050,6 +1051,30 @@ func (t *AwsConnection) Codebuild(region string) *codebuild.Client {
10501051
return client
10511052
}
10521053

1054+
func (t *AwsConnection) CodeDeploy(region string) *codedeploy.Client {
1055+
// if no region value is sent in, use the configured region
1056+
if len(region) == 0 {
1057+
region = t.cfg.Region
1058+
}
1059+
cacheVal := "_codedeploy" + region
1060+
1061+
// check for cached client and return it if it exists
1062+
c, ok := t.clientcache.Load(cacheVal)
1063+
if ok {
1064+
log.Debug().Msg("use cached codebuild client")
1065+
return c.Data.(*codedeploy.Client)
1066+
}
1067+
1068+
// create the client
1069+
cfg := t.cfg.Copy()
1070+
cfg.Region = region
1071+
client := codedeploy.NewFromConfig(cfg)
1072+
1073+
// cache it
1074+
t.clientcache.Store(cacheVal, &CacheEntry{Data: client})
1075+
return client
1076+
}
1077+
10531078
func (t *AwsConnection) Emr(region string) *emr.Client {
10541079
// if no region value is sent in, use the configured region
10551080
if len(region) == 0 {

providers/aws/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ require (
2323
github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.45.0
2424
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.50.0
2525
github.com/aws/aws-sdk-go-v2/service/codebuild v1.61.0
26+
github.com/aws/aws-sdk-go-v2/service/codedeploy v1.30.3
2627
github.com/aws/aws-sdk-go-v2/service/configservice v1.52.3
2728
github.com/aws/aws-sdk-go-v2/service/databasemigrationservice v1.52.0
2829
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.43.1

providers/aws/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.50.0 h1:t/xT0VNZUj9oQmzQj
189189
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.50.0/go.mod h1:uo14VBn5cNk/BPGTPz3kyLBxgpgOObgO8lmz+H7Z4Ck=
190190
github.com/aws/aws-sdk-go-v2/service/codebuild v1.61.0 h1:i95KOXBgI8qGelzhuDY+Q+pYwaUkIelwwEnqflpy1ZQ=
191191
github.com/aws/aws-sdk-go-v2/service/codebuild v1.61.0/go.mod h1:13SjlSpfNt71ZBZZqLMSy08j9jSPA9D5179dKV9RRz4=
192+
github.com/aws/aws-sdk-go-v2/service/codedeploy v1.30.3 h1:6gvzjZYWlzDuT/VQxetlunnHbGfQt6Sq6PeWLMQyqMo=
193+
github.com/aws/aws-sdk-go-v2/service/codedeploy v1.30.3/go.mod h1:32JRv9exrmbpVxDJc0aoovh4K2CxStudvLctugWBR/o=
192194
github.com/aws/aws-sdk-go-v2/service/configservice v1.52.3 h1:Gw9GpbCShTzWPezPKdiV8yGFbQ/yLb+NircxQUGXC0I=
193195
github.com/aws/aws-sdk-go-v2/service/configservice v1.52.3/go.mod h1:nJdDaoBiWBPdMaARQFA5xXHS0CHpxRzGbdp7QYqAVK0=
194196
github.com/aws/aws-sdk-go-v2/service/databasemigrationservice v1.52.0 h1:sL+/hCtgDrWmnbEBha9DgoUt2gw0Iw8bgnh2591nBkE=

providers/aws/resources/aws.lr

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3648,3 +3648,113 @@ private aws.timestream.liveanalytics.table @defaults("name region") {
36483648
// Retention duration properties for the table
36493649
retentionProperties dict
36503650
}
3651+
3652+
// AWS CodeDeploy
3653+
aws.codedeploy {
3654+
// List of CodeDeploy applications across all enabled regions
3655+
applications() []aws.codedeploy.application
3656+
}
3657+
3658+
// AWS CodeDeploy Application
3659+
private aws.codedeploy.application @defaults("applicationName computePlatform createdAt region") {
3660+
// ARN of the application
3661+
arn string
3662+
// ID of the application
3663+
applicationId string
3664+
// Name of the application
3665+
applicationName string
3666+
// Compute platform of the application (Server, Lambda, or ECS)
3667+
computePlatform string
3668+
// Time the application was created
3669+
createdAt time
3670+
// Whether the application is linked to a GitHub account
3671+
linkedToGitHub bool
3672+
// Tags for the application
3673+
tags() map[string]string
3674+
// List of deployment groups for this application
3675+
deploymentGroups() []aws.codedeploy.deploymentGroup
3676+
// List of deployments for this application
3677+
deployments() []aws.codedeploy.deployment
3678+
// Region of the application
3679+
region string
3680+
}
3681+
3682+
// AWS CodeDeploy Deployment Group
3683+
private aws.codedeploy.deploymentGroup @defaults("deploymentGroupName computePlatform deploymentGroupId region") {
3684+
// Application name this deployment group belongs to
3685+
applicationName string
3686+
// ARN of the deployment group
3687+
arn string
3688+
// ID of the deployment group
3689+
deploymentGroupId string
3690+
// Name of the deployment group
3691+
deploymentGroupName string
3692+
// Compute platform of the deployment group (Server, Lambda, or ECS)
3693+
computePlatform string
3694+
// Service role ARN for the deployment group
3695+
serviceRoleArn string
3696+
// Target revision for the deployment group (includes type, location, etc.)
3697+
targetRevision() dict
3698+
// Tags for the deployment group
3699+
tags() map[string]string
3700+
// Region of the deployment group
3701+
region string
3702+
// List of deployments for this deployment group
3703+
deployments() []aws.codedeploy.deployment
3704+
// Auto scaling groups associated with the deployment group
3705+
autoScalingGroups() []aws.autoscaling.group
3706+
// EC2 tag filters for the deployment group
3707+
ec2TagFilters() []dict
3708+
// On-premises instance tag filters for the deployment group
3709+
onPremisesInstanceTagFilters() []dict
3710+
// Last successful deployment information
3711+
lastSuccessfulDeployment() aws.codedeploy.deployment
3712+
// Last attempted deployment information
3713+
lastAttemptedDeployment() aws.codedeploy.deployment
3714+
// Deployment style (BLUE_GREEN or IN_PLACE)
3715+
deploymentStyle() dict
3716+
// Blue/green deployment configuration
3717+
blueGreenDeploymentConfiguration() dict
3718+
// Load balancer info
3719+
loadBalancerInfo() dict
3720+
}
3721+
3722+
// AWS CodeDeploy Deployment
3723+
private aws.codedeploy.deployment @defaults("deploymentId status applicationName deploymentGroupName createdAt region") {
3724+
// Application name for the deployment
3725+
applicationName string
3726+
// Deployment ID
3727+
deploymentId string
3728+
// ARN of the deployment (Note: Deployments themselves don't have ARNs, this will be a synthetic ID or the deploymentId itself)
3729+
arn string
3730+
// Status of the deployment (Created, Queued, InProgress, Succeeded, Failed, Stopped, Ready)
3731+
status string
3732+
// Deployment group name
3733+
deploymentGroupName string
3734+
// Deployment configuration name
3735+
deploymentConfigName string
3736+
// Time the deployment was created
3737+
createdAt time
3738+
// Time the deployment was completed
3739+
compleatedAt time
3740+
// Description of the deployment
3741+
description string
3742+
// Creator of the deployment (user, autoscaling, codeDeployRollback, etc.)
3743+
creator string
3744+
// Whether to ignore application stop failures
3745+
ignoreApplicationStopFailures bool
3746+
// Information about the instances targeted by the deployment (complex structure, represented as dict)
3747+
targetInstances() dict
3748+
// Revision information for the deployment (S3 location, GitHub location, etc.)
3749+
revision() dict
3750+
// Region of the deployment
3751+
region string
3752+
// Error information, if any
3753+
errorInformation() dict
3754+
// Deployment overview (counts for Pending, InProgress, Succeeded, Failed, Skipped, Ready)
3755+
deploymentOverview() dict
3756+
// Whether this deployment is a rollback
3757+
isRollback bool
3758+
// Rollback information if this deployment is a rollback or was rolled back
3759+
rollbackInfo() dict
3760+
}

0 commit comments

Comments
 (0)