Skip to content

Commit

Permalink
Allow sending SES emails using domain identity
Browse files Browse the repository at this point in the history
  • Loading branch information
MikkoKauhanen committed Jan 20, 2025
1 parent f65c012 commit 99d1b41
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions aoe-infra/bin/infra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,20 @@ if (environmentName === 'dev' || environmentName === 'qa' || environmentName ===
vpc: Network.vpc
})

let sesIamPolicy: iam.PolicyStatement | undefined;

if (environmentName !== 'prod') {
new SesStack(app, 'SesStack', {
const sesStack = new SesStack(app, 'SesStack', {
env: { region: 'eu-west-1' },
hostedZone: HostedZones.publicHostedZone
});

sesIamPolicy = new iam.PolicyStatement({
actions: ['ses:SendEmail'],
resources: [
sesStack.emailIdentity.emailIdentityArn
]
});
}

const SecurityGroups = new SecurityGroupStack(app, 'SecurityGroupStack', {
Expand Down Expand Up @@ -430,13 +439,6 @@ if (environmentName === 'dev' || environmentName === 'qa' || environmentName ===
resources: [efs.fileSystem.fileSystemArn]
})

const sesIamPolicy = new iam.PolicyStatement({
actions: ['ses:SendEmail'],
resources: [
'*'
]
});

new EcsServiceStack(app, 'WebBackendEcsService', {
env: { region: 'eu-west-1' },
stackName: `${environmentName}-web-backend-service`,
Expand Down Expand Up @@ -489,7 +491,7 @@ if (environmentName === 'dev' || environmentName === 'qa' || environmentName ===
efsPolicyStatement,
kafkaClusterIamPolicy,
kafkaTopicIamPolicy,
sesIamPolicy
...(sesIamPolicy ? [sesIamPolicy] : []),
],
privateDnsNamespace: namespace.privateDnsNamespace,
efs: {
Expand Down

0 comments on commit 99d1b41

Please sign in to comment.