This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
101 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 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,4 @@ | ||
export const TAGS = { | ||
team: 'pedaki', | ||
repository: 'infrastructure', | ||
}; |
This file contains 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 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,81 @@ | ||
import * as aws from '@pulumi/aws'; | ||
import * as cloudflare from '@pulumi/cloudflare'; | ||
import { env } from '../../env'; | ||
import { TAGS } from '../constants'; | ||
|
||
export const createEncryptedBucket = () => { | ||
const bucket = new aws.s3.Bucket('encrypted.pedaki.fr', { | ||
bucket: 'encrypted.pedaki.fr', | ||
acl: 'private', | ||
serverSideEncryptionConfiguration: { | ||
rule: { | ||
applyServerSideEncryptionByDefault: { | ||
sseAlgorithm: 'aws:kms', | ||
}, | ||
bucketKeyEnabled: true, | ||
}, | ||
}, | ||
tags: TAGS, | ||
}); | ||
|
||
const publicAccessBlock = new aws.s3.BucketPublicAccessBlock( | ||
'encrypted.pedaki.fr-publicAccessBlock', | ||
{ | ||
bucket: bucket.id, | ||
blockPublicAcls: true, | ||
ignorePublicAcls: true, | ||
blockPublicPolicy: true, | ||
restrictPublicBuckets: true, | ||
}, | ||
); | ||
|
||
const policy = new aws.s3.BucketPolicy( | ||
'encrypted-bucket-policy', | ||
{ | ||
bucket: bucket.id, | ||
policy: bucket.arn.apply(arn => | ||
JSON.stringify({ | ||
// all files should be encrypted | ||
Version: '2012-10-17', | ||
Statement: [ | ||
{ | ||
Sid: 'DenyUnEncryptedObjectUploads', | ||
Effect: 'Deny', | ||
Principal: '*', | ||
Action: 's3:PutObject', | ||
Resource: `${arn}/*`, | ||
Condition: { | ||
StringNotEquals: { | ||
's3:x-amz-server-side-encryption': 'aws:kms', | ||
}, | ||
}, | ||
}, | ||
{ | ||
Sid: 'DenyUnEncryptedObjectDownloads', | ||
Effect: 'Deny', | ||
Principal: '*', | ||
Action: 's3:GetObject', | ||
Resource: `${arn}/*`, | ||
Condition: { | ||
Bool: { | ||
'aws:SecureTransport': 'false', | ||
}, | ||
}, | ||
}, | ||
], | ||
}), | ||
), | ||
}, | ||
{ dependsOn: [publicAccessBlock] }, | ||
); | ||
|
||
const record = new cloudflare.Record('encrypted.pedaki.fr', { | ||
name: 'files', | ||
type: 'CNAME', | ||
value: bucket.bucketDomainName, | ||
zoneId: env.CLOUDFLARE_ZONE_ID, | ||
proxied: true, | ||
ttl: 1, // TTL must be set to 1 when proxied is true | ||
comment: `pulumi (infrastructure repo)`, | ||
}); | ||
}; |
This file contains 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 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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import * as aws from '@pulumi/aws'; | ||
import { TAGS } from '../constants'; | ||
|
||
export const createRdsParameterGroup = () => { | ||
const group = new aws.rds.ParameterGroup('rds-pedaki', { | ||
family: 'mysql8.0', | ||
description: 'Shared parameter group', | ||
name: 'rds-pedaki', | ||
parameters: [{ name: 'require_secure_transport', value: '1' }], | ||
tags: TAGS, | ||
}); | ||
}; |
This file contains 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 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 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