Socket
Socket
Sign inDemoInstall

@serverless/domain

Package Overview
Dependencies
80
Maintainers
5
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.10 to 3.0.0

2

package.json
{
"name": "@serverless/domain",
"version": "2.0.10",
"version": "3.0.0",
"main": "./serverless.js",

@@ -5,0 +5,0 @@ "publishConfig": {

@@ -19,3 +19,4 @@ const { Component } = require('@serverless/core')

getApiDomainName,
removeWebsiteDomainDnsRecords
removeWebsiteDomainDnsRecords,
addDomainToCloudfrontDistribution
} = require('./utils')

@@ -145,2 +146,15 @@

)
} else if (subdomain.type === 'awsCloudFront') {
this.context.debug(
`Adding ${subdomain.domain} domain to CloudFront distribution with URL "${subdomain.url}"`
)
await addDomainToCloudfrontDistribution(clients.cf, subdomain)
this.context.debug(`Configuring DNS for distribution "${subdomain.url}".`)
await configureDnsForCloudFrontDistribution(
clients.route53,
subdomain,
domainHostedZoneId,
subdomain.url
)
}

@@ -147,0 +161,0 @@

@@ -64,2 +64,8 @@ const aws = require('aws-sdk')

if (inputs.subdomains[subdomain].url.includes('cloudfront')) {
domainObj.distributionId = inputs.subdomains[subdomain].id
domainObj.url = inputs.subdomains[subdomain].url
domainObj.type = 'awsCloudFront'
}
subdomains.push(domainObj)

@@ -769,2 +775,54 @@ }

// const getCloudFrontDistributionByUrl = async (cf, distributionUrl) => {
// const listRes = await cf.listDistributions({}).promise()
// const distribution = listRes.DistributionList.Items.find(
// (dist) => dist.DomainName === distributionUrl
// )
// if (distribution) {
// return {
// arn: distribution.ARN,
// id: distribution.Id,
// url: distribution.DomainName,
// origins: distribution.Origins.Items.map((origin) => origin.DomainName),
// errorPages: distribution.CustomErrorResponses.Quantity === 2 ? true : false
// }
// }
// return null
// }
const addDomainToCloudfrontDistribution = async (cf, subdomain, distributionUrl) => {
// Update logic is a bit weird...
// https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudFront.html#updateDistribution-property
// 1. we gotta get the config first...
const params = await cf.getDistributionConfig({ Id: subdomain.id }).promise()
// 2. then add this property
params.IfMatch = params.ETag
// 3. then delete this property
delete params.ETag
// 4. then set this property
params.Id = subdomain.id
// 5. then make our changes
params.DistributionConfig.Aliases = {
Quantity: 1,
Items: [subdomain.domain]
}
// 6. then finally update!
const res = await cf.updateDistribution(params).promise()
return {
id: res.Distribution.Id,
arn: res.Distribution.ARN,
url: res.Distribution.DomainName
}
}
/**

@@ -795,3 +853,4 @@ * Exports

getApiDomainName,
removeWebsiteDomainDnsRecords
removeWebsiteDomainDnsRecords,
addDomainToCloudfrontDistribution
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc