Skip to content

Commit

Permalink
Migrating code to aws sdk v3
Browse files Browse the repository at this point in the history
  • Loading branch information
tstibbs committed Jan 15, 2025
1 parent 3798f9e commit 570585d
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 14 deletions.
16 changes: 16 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
These three entries are duplicated because of an old and new lighthouse - however the old lighthouse doesn't appear to still exist. They should have a demolished date on them, and then we should filter out entries with that. There might be more than just these three that get filtered out.

Fastnet Lighthouse
Hale Head Lighthouse
Hoxa Head Lighthouse

https://www.wikidata.org/wiki/Q26161442
"dissolved, abolished or demolished date"

also demolished:
Seaton Carew lighthouse

TODO:

- order the things in the outputted datasource, so that things with duplicate names can't keep swapping places and causing spurious entries in the report
- include the wikidata id in the outputted data, it's no use to the front-end but is useful to the data process, so worth the slight increase in data
142 changes: 142 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"devDependencies": {
"@aws-sdk/client-cloudformation": "^3.726.1",
"@aws-sdk/client-s3": "^3.726.1",
"@aws-sdk/lib-storage": "^3.726.1",
"@tstibbs/cloud-core-utils": "file:../../cloud-core/aws/utils",
"aws-cdk": "2.140.0",
"aws-cdk-lib": "2.140.0",
Expand Down
29 changes: 15 additions & 14 deletions backend/tools/upload.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import {strict as assert} from 'assert'
import {createReadStream} from 'fs'

import aws from 'aws-sdk'
import {CloudFormation} from '@aws-sdk/client-cloudformation'
import {Upload} from '@aws-sdk/lib-storage'
import {S3} from '@aws-sdk/client-s3'

import {defaultAwsClientConfig} from '@tstibbs/cloud-core-utils/src/tools/aws-client-config.js'
import {STACK_NAME} from '../lib/deploy-envs.js'

const GB_DATA_PATH = 'data'

aws.config.region = 'eu-west-2'
aws.config.apiVersions = {
s3: '2006-03-01',
cloudformation: '2010-05-15'
}
let cloudformation = new aws.CloudFormation()
let s3 = new aws.S3()
let cloudformation = new CloudFormation(defaultAwsClientConfig)
let s3 = new S3(defaultAwsClientConfig)

const args = process.argv.slice(2)
if (args.length < 1) {
Expand Down Expand Up @@ -44,12 +42,15 @@ async function upload(prefix, fileName, body, contentType) {
key = fileName
}
console.log(`Uploading ${key}`)
let uploadResponse = await s3.upload({
Bucket: bucketName,
Key: key,
Body: body,
ContentType: contentType
})
let uploadResponse = await new Upload({
client: s3,
params: {
Bucket: bucketName,
Key: key,
Body: body,
ContentType: contentType
}
}).done()

assert.notEqual(uploadResponse.Location, null)
assert.notEqual(uploadResponse.Location, undefined)
Expand Down

0 comments on commit 570585d

Please sign in to comment.