feat: setup AWS CDK app and create hosted zone for tradhox.com
This commit is contained in:
parent
29ec526511
commit
b9085ebc45
12 changed files with 250 additions and 1 deletions
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
*.swp
|
||||
__pycache__
|
||||
.pytest_cache
|
||||
.venv
|
||||
*.egg-info
|
||||
|
||||
# CDK asset staging directory
|
||||
.cdk.staging
|
||||
cdk.out
|
||||
59
README.md
59
README.md
|
|
@ -1 +1,58 @@
|
|||
# Tradhox Domain Settings
|
||||
|
||||
# Welcome to your CDK Python project!
|
||||
|
||||
This is a blank project for CDK development with Python.
|
||||
|
||||
The `cdk.json` file tells the CDK Toolkit how to execute your app.
|
||||
|
||||
This project is set up like a standard Python project. The initialization
|
||||
process also creates a virtualenv within this project, stored under the `.venv`
|
||||
directory. To create the virtualenv it assumes that there is a `python3`
|
||||
(or `python` for Windows) executable in your path with access to the `venv`
|
||||
package. If for any reason the automatic creation of the virtualenv fails,
|
||||
you can create the virtualenv manually.
|
||||
|
||||
To manually create a virtualenv on MacOS and Linux:
|
||||
|
||||
```
|
||||
$ python3 -m venv .venv
|
||||
```
|
||||
|
||||
After the init process completes and the virtualenv is created, you can use the following
|
||||
step to activate your virtualenv.
|
||||
|
||||
```
|
||||
$ source .venv/bin/activate
|
||||
```
|
||||
|
||||
If you are a Windows platform, you would activate the virtualenv like this:
|
||||
|
||||
```
|
||||
% .venv\Scripts\activate.bat
|
||||
```
|
||||
|
||||
Once the virtualenv is activated, you can install the required dependencies.
|
||||
|
||||
```
|
||||
$ pip install -r requirements.txt
|
||||
```
|
||||
|
||||
At this point you can now synthesize the CloudFormation template for this code.
|
||||
|
||||
```
|
||||
$ cdk synth
|
||||
```
|
||||
|
||||
To add additional dependencies, for example other CDK libraries, just add
|
||||
them to your `requirements.txt` file and rerun the `python -m pip install -r requirements.txt`
|
||||
command.
|
||||
|
||||
## Useful commands
|
||||
|
||||
* `cdk ls` list all stacks in the app
|
||||
* `cdk synth` emits the synthesized CloudFormation template
|
||||
* `cdk deploy` deploy this stack to your default AWS account/region
|
||||
* `cdk diff` compare deployed stack with current state
|
||||
* `cdk docs` open CDK documentation
|
||||
|
||||
Enjoy!
|
||||
|
|
|
|||
28
app.py
Normal file
28
app.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
|
||||
import aws_cdk as cdk
|
||||
|
||||
from tradhoxdomain.tradhoxdomain_stack import TradhoxdomainStack
|
||||
|
||||
|
||||
app = cdk.App()
|
||||
TradhoxdomainStack(app, "TradhoxdomainStack",
|
||||
# If you don't specify 'env', 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.
|
||||
|
||||
# Uncomment the next line to specialize this stack for the AWS Account
|
||||
# and Region that are implied by the current CLI configuration.
|
||||
|
||||
#env=cdk.Environment(account=os.getenv('CDK_DEFAULT_ACCOUNT'), region=os.getenv('CDK_DEFAULT_REGION')),
|
||||
|
||||
# Uncomment the next line if you know exactly what Account and Region you
|
||||
# want to deploy the stack to. */
|
||||
|
||||
#env=cdk.Environment(account='123456789012', region='us-east-1'),
|
||||
|
||||
# For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html
|
||||
)
|
||||
|
||||
app.synth()
|
||||
108
cdk.json
Normal file
108
cdk.json
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"app": "python3 app.py",
|
||||
"watch": {
|
||||
"include": [
|
||||
"**"
|
||||
],
|
||||
"exclude": [
|
||||
"README.md",
|
||||
"cdk*.json",
|
||||
"requirements*.txt",
|
||||
"source.bat",
|
||||
"**/__init__.py",
|
||||
"**/__pycache__",
|
||||
"tests"
|
||||
]
|
||||
},
|
||||
"context": {
|
||||
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
|
||||
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
|
||||
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
|
||||
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
|
||||
"@aws-cdk/aws-appsync:appSyncGraphQLAPIScopeLambdaPermission": true,
|
||||
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
|
||||
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
|
||||
"@aws-cdk/aws-batch:defaultToAL2023": true,
|
||||
"@aws-cdk/aws-cloudfront:defaultFunctionRuntimeV2_0": true,
|
||||
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
|
||||
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
|
||||
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
|
||||
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
|
||||
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
|
||||
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
|
||||
"@aws-cdk/aws-dynamodb:resourcePolicyPerReplica": true,
|
||||
"@aws-cdk/aws-dynamodb:retainTableReplica": true,
|
||||
"@aws-cdk/aws-ec2:bastionHostUseAmazonLinux2023ByDefault": true,
|
||||
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
|
||||
"@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": true,
|
||||
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
|
||||
"@aws-cdk/aws-ec2:requirePrivateSubnetsForEgressOnlyInternetGateway": true,
|
||||
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
|
||||
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
|
||||
"@aws-cdk/aws-ecs-patterns:secGroupsDisablesImplicitOpenListener": true,
|
||||
"@aws-cdk/aws-ecs-patterns:uniqueTargetGroupId": true,
|
||||
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
|
||||
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
|
||||
"@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": true,
|
||||
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
|
||||
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
|
||||
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
|
||||
"@aws-cdk/aws-eks:defaultToAL2023": true,
|
||||
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
|
||||
"@aws-cdk/aws-eks:useNativeOidcProvider": true,
|
||||
"@aws-cdk/aws-elasticloadbalancingV2:albDualstackWithoutPublicIpv4SecurityGroupRulesDefault": true,
|
||||
"@aws-cdk/aws-elasticloadbalancingv2:networkLoadBalancerWithSecurityGroupByDefault": true,
|
||||
"@aws-cdk/aws-elasticloadbalancingv2:usePostQuantumTlsPolicy": true,
|
||||
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
|
||||
"@aws-cdk/aws-events:requireEventBusPolicySid": true,
|
||||
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
|
||||
"@aws-cdk/aws-iam:minimizePolicies": true,
|
||||
"@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections": true,
|
||||
"@aws-cdk/aws-kms:aliasNameRef": true,
|
||||
"@aws-cdk/aws-kms:applyImportedAliasPermissionsToPrincipal": true,
|
||||
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
|
||||
"@aws-cdk/aws-lambda-nodejs:sdkV3ExcludeSmithyPackages": true,
|
||||
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
|
||||
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": false,
|
||||
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
|
||||
"@aws-cdk/aws-lambda:useCdkManagedLogGroup": true,
|
||||
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
|
||||
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
|
||||
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
|
||||
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
|
||||
"@aws-cdk/aws-rds:setCorrectValueForDatabaseInstanceReadReplicaInstanceResourceId": true,
|
||||
"@aws-cdk/aws-redshift:columnId": true,
|
||||
"@aws-cdk/aws-route53-patterns:useDistribution": true,
|
||||
"@aws-cdk/aws-route53-patters:useCertificate": true,
|
||||
"@aws-cdk/aws-route53-targets:userPoolDomainNameMethodWithoutCustomResource": true,
|
||||
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
|
||||
"@aws-cdk/aws-s3:keepNotificationInImportedBucket": false,
|
||||
"@aws-cdk/aws-s3:publicAccessBlockedByDefault": true,
|
||||
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
|
||||
"@aws-cdk/aws-s3:setUniqueReplicationRoleName": true,
|
||||
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
|
||||
"@aws-cdk/aws-signer:signingProfileNamePassedToCfn": true,
|
||||
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
|
||||
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
|
||||
"@aws-cdk/aws-stepfunctions-tasks:fixRunEcsTaskPolicy": true,
|
||||
"@aws-cdk/aws-stepfunctions:useDistributedMapResultWriterV2": true,
|
||||
"@aws-cdk/core:annotationsInValidationReport": true,
|
||||
"@aws-cdk/core:aspectPrioritiesMutating": true,
|
||||
"@aws-cdk/core:cfnIncludeRejectComplexResourceUpdateCreatePolicyIntrinsics": true,
|
||||
"@aws-cdk/core:checkSecretUsage": true,
|
||||
"@aws-cdk/core:defaultCrossStackReferences": "weak",
|
||||
"@aws-cdk/core:enableAdditionalMetadataCollection": true,
|
||||
"@aws-cdk/core:enablePartitionLiterals": true,
|
||||
"@aws-cdk/core:explicitStackTags": true,
|
||||
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
|
||||
"@aws-cdk/core:target-partitions": [
|
||||
"aws",
|
||||
"aws-cn"
|
||||
],
|
||||
"@aws-cdk/core:validateAgainstDefaultRules": true,
|
||||
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
|
||||
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false,
|
||||
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
|
||||
"@aws-cdk/s3-notifications:addS3TrustKeyPolicyForSnsSubscriptions": true
|
||||
}
|
||||
}
|
||||
1
requirements-dev.txt
Normal file
1
requirements-dev.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
pytest==8.4.2
|
||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
aws-cdk-lib>=2.267.0,<3.0.0
|
||||
constructs>=10.5.0,<11.0.0
|
||||
13
source.bat
Normal file
13
source.bat
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
@echo off
|
||||
|
||||
rem The sole purpose of this script is to make the command
|
||||
rem
|
||||
rem source .venv/bin/activate
|
||||
rem
|
||||
rem (which activates a Python virtualenv on Linux or Mac OS X) work on Windows.
|
||||
rem On Windows, this command just runs this batch file (the argument is ignored).
|
||||
rem
|
||||
rem Now we don't need to document a Windows command for activating a virtualenv.
|
||||
|
||||
echo Executing .venv\Scripts\activate.bat for you
|
||||
.venv\Scripts\activate.bat
|
||||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
0
tests/unit/__init__.py
Normal file
0
tests/unit/__init__.py
Normal file
15
tests/unit/test_tradhoxdomain_stack.py
Normal file
15
tests/unit/test_tradhoxdomain_stack.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import aws_cdk as core
|
||||
import aws_cdk.assertions as assertions
|
||||
|
||||
from tradhoxdomain.tradhoxdomain_stack import TradhoxdomainStack
|
||||
|
||||
# example tests. To run these tests, uncomment this file along with the example
|
||||
# resource in tradhoxdomain/tradhoxdomain_stack.py
|
||||
def test_sqs_queue_created():
|
||||
app = core.App()
|
||||
stack = TradhoxdomainStack(app, "tradhoxdomain")
|
||||
template = assertions.Template.from_stack(stack)
|
||||
|
||||
# template.has_resource_properties("AWS::SQS::Queue", {
|
||||
# "VisibilityTimeout": 300
|
||||
# })
|
||||
0
tradhoxdomain/__init__.py
Normal file
0
tradhoxdomain/__init__.py
Normal file
16
tradhoxdomain/tradhoxdomain_stack.py
Normal file
16
tradhoxdomain/tradhoxdomain_stack.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from aws_cdk import (
|
||||
Stack,
|
||||
aws_route53 as route53,
|
||||
)
|
||||
from constructs import Construct
|
||||
|
||||
class TradhoxdomainStack(Stack):
|
||||
|
||||
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
|
||||
super().__init__(scope, construct_id, **kwargs)
|
||||
|
||||
# Create a Hosted Zone for tradhox.com
|
||||
hosted_zone = route53.PublicHostedZone(
|
||||
self, "TradhoxHostedZone",
|
||||
zone_name="tradhox.com"
|
||||
)
|
||||
Loading…
Reference in a new issue