Skip to content

Commit b2cd957

Browse files
committed
chore: wip
1 parent b8e3ba3 commit b2cd957

File tree

4 files changed

+41
-18
lines changed

4 files changed

+41
-18
lines changed

.stacks/core/cloud/src/cloud.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
Stack,
1111
aws_certificatemanager as acm,
1212
aws_cloudfront as cloudfront,
13+
custom_resources,
1314
aws_ec2 as ec2,
1415
aws_efs as efs,
1516
aws_iam as iam,
@@ -270,13 +271,14 @@ export class StacksCloud extends Stack {
270271
manageUsers() {
271272
const teamName = config.team.name
272273
const users = config.team.members
274+
const password = env.AWS_DEFAULT_PASSWORD || string.random()
273275

274276
for (const userName in users) {
275277
// const userEmail = users[userName]
276278
const name = `${string.pascalCase(teamName)}${string.pascalCase(userName)}User`
277279
const user = new iam.User(this, name, {
278280
userName,
279-
password: SecretValue.unsafePlainText(env.AWS_DEFAULT_PASSWORD || string.random()),
281+
password: SecretValue.unsafePlainText(password),
280282
passwordResetRequired: true,
281283
})
282284

@@ -293,11 +295,33 @@ export class StacksCloud extends Stack {
293295
domainName: this.domain,
294296
})
295297

298+
// TODO: fix this – redirects do not work yet
296299
config.dns.redirects?.forEach((redirect) => {
297300
const slug = redirect.split('.').map((part, index) => index === 0 ? part : part.charAt(0).toUpperCase() + part.slice(1)).join('') // creates a CamelCase slug from the redirect
298301
const hostedZone = route53.HostedZone.fromLookup(this, `RedirectHostedZone${slug}`, { domainName: redirect })
299302
this.redirectZones.push(hostedZone)
300303
})
304+
305+
new custom_resources.AwsCustomResource(this, 'VerifyDomainIdentity', {
306+
onCreate: {
307+
service: 'SES',
308+
action: 'verifyDomainIdentity',
309+
parameters: {
310+
Domain: this.domain,
311+
},
312+
physicalResourceId: custom_resources.PhysicalResourceId.of('VerifyDomainIdentity'),
313+
},
314+
policy: custom_resources.AwsCustomResourcePolicy.fromSdkCalls({ resources: custom_resources.AwsCustomResourcePolicy.ANY_RESOURCE }),
315+
})
316+
317+
new route53.MxRecord(this, 'MxRecord', {
318+
zone: this.zone,
319+
recordName: this.domain,
320+
values: [{
321+
priority: 10,
322+
hostName: 'inbound-smtp.us-east-1.amazonaws.com', // Replace with your SES inbound endpoint
323+
}],
324+
})
301325
}
302326
// if not, lets create it
303327
catch (error) {

.stacks/core/cloud/src/drivers/aws/email-forwarder.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,29 @@ console.log('AWS Lambda SES Forwarder')
3737
//
3838
// To match all email addresses matching no other mapping, use "@" as a key.
3939
const defaultConfig = {
40-
fromEmail: 'noreply@example.com',
40+
fromEmail: 'noreply@stacksjs.org',
4141
subjectPrefix: '',
42-
emailBucket: 's3-bucket-name',
43-
emailKeyPrefix: 'emailsPrefix/',
42+
emailBucket: 'stacksjs.org-email',
43+
emailKeyPrefix: 'stacks/',
4444
allowPlusSign: true,
4545
forwardMapping: {
46-
'info@example.com': [
47-
'example.john@example.com',
48-
'example.jen@example.com',
46+
'hello@stacksjs.org': [
47+
'chrisbreuer93@gmail.com',
4948
],
50-
'abuse@example.com': [
51-
'example.jim@example.com',
52-
],
53-
'@example.com': [
54-
'example.john@example.com',
55-
],
56-
'info': [
57-
'info@example.com',
49+
// 'abuse@example.com': [
50+
// 'example.jim@example.com',
51+
// ],
52+
'@stacksjs.org': [
53+
'chrisbreuer93@gmail.com',
5854
],
55+
// 'info': [
56+
// 'info@example.com',
57+
// ],
5958
},
6059
}
6160

6261
/**
63-
* Parses the SES event record provided for the `mail` and `receipients` data.
62+
* Parses the SES event record provided for the `mail` and `recipients` data.
6463
*
6564
* @param {object} data - Data bundle with context, email, etc.
6665
*

.stacks/core/env/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function process() {
4141
: p.env as unknown as Env
4242
}
4343

44-
export const env = new Proxy(process(), handler)
44+
export const env: Env = new Proxy(process(), handler)
4545

4646
export function writeEnv(key: EnvKey, value: string, options?: { path: string }) {
4747
const envPath = options?.path || projectPath('.env')

config/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default {
1313
accountId: env.AWS_ACCOUNT_ID || '',
1414
appId: env.AWS_ACCESS_KEY_ID || '',
1515
apiKey: env.AWS_SECRET_ACCESS_KEY || '',
16-
region: env.AWS_DEFAULT_REGION || '',
16+
region: env.AWS_DEFAULT_REGION || 'us-east-1',
1717
},
1818

1919
algolia: {

0 commit comments

Comments
 (0)