-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add initial AWS implementation #24
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
Closed
Closed
Changes from 8 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4c9522f
feat: add initial AWS implementation
jeastham1993 0137212
Update user-management/infra/aws/src/Program.cs
jeastham1993 58a182b
Update user-management/src/Stickerlandia.UserManagement.AWS/SnsEventP…
jeastham1993 7970f88
fix: update thrown exception
jeastham1993 4932b2c
fix: delete message from queue after sending to DLQ
jeastham1993 62f32d1
fix: remove hardcoded connection string
jeastham1993 ba7ecdf
Update user-management/src/Stickerlandia.UserManagement.AWS/SqsSticke…
jeastham1993 d926b1b
Merge branch 'feat/aws-impl' of github.com:DataDog/stickerlandia into…
jeastham1993 29989e1
Merge branch 'main' into feat/aws-impl
jeastham1993 f9d0c75
feat: update AWS implementation
jeastham1993 3a331e1
feat: update Azure IaC
jeastham1993 8453308
fix: remove data
jeastham1993 cd77045
feat: update AWS implementation
jeastham1993 0de8cdd
feat: update Azure IaC
jeastham1993 50929e8
fix: remove data
jeastham1993 b6070b9
feat: update integration tests
jeastham1993 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,94 @@ | ||
| { | ||
| "app": "dotnet run --project src/UserManagementService.csproj", | ||
| "watch": { | ||
| "include": [ | ||
| "**" | ||
| ], | ||
| "exclude": [ | ||
| "README.md", | ||
| "cdk*.json", | ||
| "src/*/obj", | ||
| "src/*/bin", | ||
| "src/*.sln", | ||
| "src/*/GlobalSuppressions.cs", | ||
| "src/*/*.csproj" | ||
| ] | ||
| }, | ||
| "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-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, | ||
| "@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true, | ||
| "@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true, | ||
| "@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true, | ||
| "@aws-cdk/aws-eks:nodegroupNameAttribute": true, | ||
| "@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true, | ||
| "@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true, | ||
| "@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false, | ||
| "@aws-cdk/aws-s3:keepNotificationInImportedBucket": false, | ||
| "@aws-cdk/aws-ecs:enableImdsBlockingDeprecatedFeature": false, | ||
| "@aws-cdk/aws-ecs:disableEcsImdsBlocking": true, | ||
| "@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": true, | ||
| "@aws-cdk/aws-dynamodb:resourcePolicyPerReplica": true, | ||
| "@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": true, | ||
| "@aws-cdk/aws-appsync:appSyncGraphQLAPIScopeLambdaPermission": true, | ||
| "@aws-cdk/aws-rds:setCorrectValueForDatabaseInstanceReadReplicaInstanceResourceId": true, | ||
| "@aws-cdk/core:cfnIncludeRejectComplexResourceUpdateCreatePolicyIntrinsics": true, | ||
| "@aws-cdk/aws-lambda-nodejs:sdkV3ExcludeSmithyPackages": true, | ||
| "@aws-cdk/aws-stepfunctions-tasks:fixRunEcsTaskPolicy": true, | ||
| "@aws-cdk/aws-ec2:bastionHostUseAmazonLinux2023ByDefault": true, | ||
| "@aws-cdk/aws-route53-targets:userPoolDomainNameMethodWithoutCustomResource": true, | ||
| "@aws-cdk/aws-elasticloadbalancingV2:albDualstackWithoutPublicIpv4SecurityGroupRulesDefault": true, | ||
| "@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections": true, | ||
| "@aws-cdk/core:enableAdditionalMetadataCollection": true, | ||
| "@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": false, | ||
| "@aws-cdk/aws-s3:setUniqueReplicationRoleName": true, | ||
| "@aws-cdk/aws-events:requireEventBusPolicySid": true, | ||
| "@aws-cdk/core:aspectPrioritiesMutating": true, | ||
| "@aws-cdk/aws-dynamodb:retainTableReplica": true, | ||
| "@aws-cdk/aws-stepfunctions:useDistributedMapResultWriterV2": true, | ||
| "@aws-cdk/s3-notifications:addS3TrustKeyPolicyForSnsSubscriptions": true, | ||
| "@aws-cdk/aws-ec2:requirePrivateSubnetsForEgressOnlyInternetGateway": true, | ||
| "@aws-cdk/aws-s3:publicAccessBlockedByDefault": true | ||
| } | ||
| } |
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 @@ | ||
| [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Quality Issues", "RECS0026:Possible unassigned object created by 'new'", Justification = "Constructs add themselves to the scope in which they are created")] |
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,96 @@ | ||
| // Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| // Copyright 2024 Datadog, Inc. | ||
|
|
||
| using System; | ||
| using Amazon.CDK; | ||
| using Amazon.CDK.AWS.IAM; | ||
| using Amazon.CDK.AWS.Lambda; | ||
| using Amazon.CDK.AWS.Lambda.DotNet; | ||
| using Amazon.CDK.AWS.Logs; | ||
| using Constructs; | ||
| using Environment = System.Environment; | ||
|
|
||
| namespace UserManagementService; | ||
|
|
||
| public record FunctionProps( | ||
| SharedProps Shared, | ||
| string FunctionName, | ||
| string ProjectPath, | ||
| string Handler, | ||
| Dictionary<string, string> EnvironmentVariables); | ||
|
|
||
| public class InstrumentedFunction : Construct | ||
| { | ||
| public IFunction Function { get; private set; } | ||
|
|
||
| public InstrumentedFunction(Construct scope, string id, FunctionProps props) : base(scope, id) | ||
| { | ||
| if (props.Handler.Length > 128) | ||
| throw new ArgumentException( | ||
| "Function handler cannot be greater than 128 chars. https://docs.aws.amazon.com/lambda/latest/api/API_CreateFunction.html#lambda-CreateFunction-request-Handler"); | ||
| var functionName = $"{props.Shared.ServiceName}-{props.FunctionName}-{props.Shared.Env}"; | ||
|
|
||
| if (functionName.Length > 64) | ||
| { | ||
| var extraCharacters = functionName.Length - 64; | ||
|
|
||
| functionName = | ||
| $"{props.Shared.ServiceName}-{props.FunctionName.Substring(0, props.FunctionName.Length - extraCharacters)}-{props.Shared.Env}"; | ||
| } | ||
|
|
||
| var defaultEnvironmentVariables = new Dictionary<string, string>() | ||
| { | ||
| { "POWERTOOLS_SERVICE_NAME", props.Shared.ServiceName }, | ||
| { "POWERTOOLS_LOG_LEVEL", "DEBUG" }, | ||
| { "AWS_LAMBDA_EXEC_WRAPPER", "/opt/datadog_wrapper" }, | ||
| { "DD_SITE", Environment.GetEnvironmentVariable("DD_SITE") }, | ||
| { "DD_ENV", props.Shared.Env }, | ||
| { "ENV", props.Shared.Env }, | ||
| { "DD_VERSION", props.Shared.Version }, | ||
| { "DD_SERVICE", props.Shared.ServiceName }, | ||
| { "DD_API_KEY_SECRET_ARN", props.Shared.DDApiKeySecret.SecretArn }, | ||
| { "DD_CAPTURE_LAMBDA_PAYLOAD", "true" }, | ||
| { "DOMAIN", props.Shared.Domain }, | ||
| { "TEAM", props.Shared.Team } | ||
| }; | ||
|
|
||
| Function = new DotNetFunction(this, id, | ||
| new DotNetFunctionProps | ||
| { | ||
| ProjectDir = props.ProjectPath, | ||
| Handler = props.Handler, | ||
| MemorySize = 1024, | ||
| Timeout = Duration.Seconds(29), | ||
| Runtime = Runtime.DOTNET_8, | ||
| Environment = defaultEnvironmentVariables.Union(props.EnvironmentVariables) | ||
| .ToDictionary(x => x.Key, x => x.Value), | ||
| Architecture = Architecture.ARM_64, | ||
| FunctionName = functionName, | ||
| LogRetention = RetentionDays.ONE_DAY, | ||
| Layers = | ||
| [ | ||
| LayerVersion.FromLayerVersionArn(this, "DDExtension", | ||
| $"arn:aws:lambda:{Environment.GetEnvironmentVariable("AWS_REGION") ?? "us-east-1"}:464622532012:layer:Datadog-Extension-ARM:80"), | ||
| LayerVersion.FromLayerVersionArn(this, "DDTrace", | ||
| $"arn:aws:lambda:{Environment.GetEnvironmentVariable("AWS_REGION") ?? "us-east-1"}:464622532012:layer:dd-trace-dotnet-ARM:20") | ||
| ] | ||
| }); | ||
|
|
||
| // The Datadog extension sends log data to Datadog using the telemetry API, disabling CloudWatch prevents 'double paying' for logs | ||
| if (Environment.GetEnvironmentVariable("ENABLE_CLOUDWATCH_LOGS") != "Y") | ||
| Function.AddToRolePolicy(new PolicyStatement(new PolicyStatementProps() | ||
| { | ||
| Resources = new[] { "arn:aws:logs:*:*:*" }, | ||
| Actions = new[] | ||
| { | ||
| "logs:CreateLogGroup", | ||
| "logs:CreateLogStream", | ||
| "logs:PutLogEvents" | ||
| }, | ||
| Effect = Effect.DENY | ||
| })); | ||
|
|
||
| props.Shared.DDApiKeySecret.GrantRead(Function); | ||
| } | ||
| } | ||
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,16 @@ | ||
| using Amazon.CDK; | ||
|
|
||
| namespace UserManagementService | ||
| { | ||
| sealed static class Program | ||
| { | ||
| public static void Main(string[] args) | ||
| { | ||
| var app = new App(); | ||
| var userManagementServiceStack = new UserManagementServiceStack(app, "UserManagementServiceStack", new StackProps()); | ||
| userManagementServiceStack.Tags.SetTag("team", "users"); | ||
| userManagementServiceStack.Tags.SetTag("domain", "users"); | ||
| app.Synth(); | ||
| } | ||
| } | ||
| } |
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,9 @@ | ||
| // Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| // Copyright 2024 Datadog, Inc. | ||
|
|
||
| using Amazon.CDK.AWS.SecretsManager; | ||
|
|
||
| namespace UserManagementService; | ||
|
|
||
| public record SharedProps(string ServiceName, string Env, string Version, string Team, string Domain, ISecret DDApiKeySecret, string DDSite); |
19 changes: 19 additions & 0 deletions
19
user-management/infra/aws/src/UserManagementService.csproj
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,19 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <!-- Roll forward to future major versions of the netcoreapp as needed --> | ||
| <RollForward>Major</RollForward> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <!-- CDK Construct Library dependencies --> | ||
| <PackageReference Include="Amazon.CDK.Lib" Version="2.200.1" /> | ||
| <PackageReference Include="Constructs" Version="10.4.2" /> | ||
| <PackageReference Include="Amazon.CDK.AWS.Lambda.DotNet" Version="0.0.6" /> | ||
| <PackageReference Include="Amazon.Jsii.Analyzers" Version="1.112.0" PrivateAssets="all" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
Oops, something went wrong.
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.