Initial commit
This commit is contained in:
commit
3c223565e3
6 changed files with 197 additions and 0 deletions
19
.gitignore
vendored
Normal file
19
.gitignore
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# go.sum should be committed
|
||||
!go.sum
|
||||
|
||||
# CDK asset staging directory
|
||||
.cdk.staging
|
||||
cdk.out
|
12
README.md
Normal file
12
README.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Welcome to your CDK Go project!
|
||||
|
||||
This is a blank project for CDK development with Go.
|
||||
|
||||
The `cdk.json` file tells the CDK toolkit how to execute your app.
|
||||
|
||||
## Useful commands
|
||||
|
||||
* `cdk deploy` deploy this stack to your default AWS account/region
|
||||
* `cdk diff` compare deployed stack with current state
|
||||
* `cdk synth` emits the synthesized CloudFormation template
|
||||
* `go test` run unit tests
|
61
cdk.json
Normal file
61
cdk.json
Normal file
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"app": "go mod download && go run cloudwatch-log-alerts.go",
|
||||
"watch": {
|
||||
"include": [
|
||||
"**"
|
||||
],
|
||||
"exclude": [
|
||||
"README.md",
|
||||
"cdk*.json",
|
||||
"go.mod",
|
||||
"go.sum",
|
||||
"**/*test.go"
|
||||
]
|
||||
},
|
||||
"context": {
|
||||
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
|
||||
"@aws-cdk/core:checkSecretUsage": true,
|
||||
"@aws-cdk/core:target-partitions": [
|
||||
"aws",
|
||||
"aws-cn"
|
||||
],
|
||||
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
|
||||
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
|
||||
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
|
||||
"@aws-cdk/aws-iam:minimizePolicies": true,
|
||||
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
|
||||
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
|
||||
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
|
||||
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
|
||||
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
|
||||
"@aws-cdk/core:enablePartitionLiterals": true,
|
||||
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
|
||||
"@aws-cdk/aws-iam:standardizedServicePrincipals": true,
|
||||
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
|
||||
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
|
||||
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
|
||||
"@aws-cdk/aws-route53-patters:useCertificate": true,
|
||||
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
|
||||
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
|
||||
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
|
||||
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
|
||||
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
|
||||
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
|
||||
"@aws-cdk/aws-redshift:columnId": true,
|
||||
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
|
||||
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
|
||||
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
|
||||
"@aws-cdk/aws-kms:aliasNameRef": true,
|
||||
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
|
||||
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
|
||||
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
|
||||
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
|
||||
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
|
||||
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
|
||||
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
|
||||
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
|
||||
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
|
||||
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
|
||||
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true
|
||||
}
|
||||
}
|
70
cloudwatch-log-alerts.go
Normal file
70
cloudwatch-log-alerts.go
Normal file
|
@ -0,0 +1,70 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-cdk-go/awscdk/v2"
|
||||
// "github.com/aws/aws-cdk-go/awscdk/v2/awssqs"
|
||||
"github.com/aws/constructs-go/constructs/v10"
|
||||
"github.com/aws/jsii-runtime-go"
|
||||
)
|
||||
|
||||
type CloudwatchLogAlertsStackProps struct {
|
||||
awscdk.StackProps
|
||||
}
|
||||
|
||||
func NewCloudwatchLogAlertsStack(scope constructs.Construct, id string, props *CloudwatchLogAlertsStackProps) awscdk.Stack {
|
||||
var sprops awscdk.StackProps
|
||||
if props != nil {
|
||||
sprops = props.StackProps
|
||||
}
|
||||
stack := awscdk.NewStack(scope, &id, &sprops)
|
||||
|
||||
// The code that defines your stack goes here
|
||||
|
||||
// example resource
|
||||
// queue := awssqs.NewQueue(stack, jsii.String("CloudwatchLogAlertsQueue"), &awssqs.QueueProps{
|
||||
// VisibilityTimeout: awscdk.Duration_Seconds(jsii.Number(300)),
|
||||
// })
|
||||
|
||||
return stack
|
||||
}
|
||||
|
||||
func main() {
|
||||
defer jsii.Close()
|
||||
|
||||
app := awscdk.NewApp(nil)
|
||||
|
||||
NewCloudwatchLogAlertsStack(app, "CloudwatchLogAlertsStack", &CloudwatchLogAlertsStackProps{
|
||||
awscdk.StackProps{
|
||||
Env: env(),
|
||||
},
|
||||
})
|
||||
|
||||
app.Synth(nil)
|
||||
}
|
||||
|
||||
// env determines the AWS environment (account+region) in which our stack is to
|
||||
// be deployed. For more information see: https://docs.aws.amazon.com/cdk/latest/guide/environments.html
|
||||
func env() *awscdk.Environment {
|
||||
// If unspecified, this stack will be "environment-agnostic".
|
||||
// Account/Region-dependent features and context lookups will not work, but a
|
||||
// single synthesized template can be deployed anywhere.
|
||||
//---------------------------------------------------------------------------
|
||||
return nil
|
||||
|
||||
// Uncomment if you know exactly what account and region you want to deploy
|
||||
// the stack to. This is the recommendation for production stacks.
|
||||
//---------------------------------------------------------------------------
|
||||
// return &awscdk.Environment{
|
||||
// Account: jsii.String("123456789012"),
|
||||
// Region: jsii.String("us-east-1"),
|
||||
// }
|
||||
|
||||
// Uncomment to specialize this stack for the AWS Account and Region that are
|
||||
// implied by the current CLI configuration. This is recommended for dev
|
||||
// stacks.
|
||||
//---------------------------------------------------------------------------
|
||||
// return &awscdk.Environment{
|
||||
// Account: jsii.String(os.Getenv("CDK_DEFAULT_ACCOUNT")),
|
||||
// Region: jsii.String(os.Getenv("CDK_DEFAULT_REGION")),
|
||||
// }
|
||||
}
|
26
cloudwatch-log-alerts_test.go
Normal file
26
cloudwatch-log-alerts_test.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
// import (
|
||||
// "testing"
|
||||
|
||||
// "github.com/aws/aws-cdk-go/awscdk/v2"
|
||||
// "github.com/aws/aws-cdk-go/awscdk/v2/assertions"
|
||||
// "github.com/aws/jsii-runtime-go"
|
||||
// )
|
||||
|
||||
// example tests. To run these tests, uncomment this file along with the
|
||||
// example resource in cloudwatch-log-alerts_test.go
|
||||
// func TestCloudwatchLogAlertsStack(t *testing.T) {
|
||||
// // GIVEN
|
||||
// app := awscdk.NewApp(nil)
|
||||
|
||||
// // WHEN
|
||||
// stack := NewCloudwatchLogAlertsStack(app, "MyStack", nil)
|
||||
|
||||
// // THEN
|
||||
// template := assertions.Template_FromStack(stack, nil)
|
||||
|
||||
// template.HasResourceProperties(jsii.String("AWS::SQS::Queue"), map[string]interface{}{
|
||||
// "VisibilityTimeout": 300,
|
||||
// })
|
||||
// }
|
9
go.mod
Normal file
9
go.mod
Normal file
|
@ -0,0 +1,9 @@
|
|||
module cloudwatch-log-alerts
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/aws/aws-cdk-go/awscdk/v2 v2.126.0
|
||||
github.com/aws/constructs-go/constructs/v10 v10.0.5
|
||||
github.com/aws/jsii-runtime-go v1.29.0
|
||||
)
|
Loading…
Reference in a new issue