New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mapbox/cloudfriend

Package Overview
Dependencies
Maintainers
161
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mapbox/cloudfriend - npm Package Compare versions

Comparing version 1.8.2 to 1.9.0

5

changelog.md

@@ -0,1 +1,6 @@

## v1.9.0
- Adds `AWS::Partition` and `AWS::DomainSuffix` pseudo-parameters
- Adds `cloudfriend.arn()`, a shortcut for constructing ARNs
## v1.8.2

@@ -2,0 +7,0 @@

15

lib/intrinsic.js

@@ -193,3 +193,2 @@ var intrinsic = module.exports = {};

/**

@@ -209,1 +208,15 @@ * [The intrinsic function Fn::Split](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-split.html)

};
/**
* Uses [the intrinsic function Fn::Sub]()
* to produce an ARN for a particular resource or set of resources.
*
* @param {string|object} service - the name of the AWS service, e.g. `s3` or `cloudformation`
* @param {string|object} suffix - the last, service-specific part of the arn
* @returns a Fn::Sub object defining the ARN
*/
intrinsic.arn = (service, suffix) => {
const replacement = { service, suffix };
if (service === 's3') return intrinsic.sub('arn:${AWS::Partition}:${service}:::${suffix}', replacement);
else return intrinsic.sub('arn:${AWS::Partition}:${service}:${AWS::Region}:${AWS::AccountId}:${suffix}', replacement);
};

@@ -69,1 +69,26 @@ var intrinsic = require('./intrinsic');

pseudo.stackName = intrinsic.ref('AWS::StackName');
/**
* [The pseudo parameter AWS::Partition](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html#cfn-pseudo-param-partition),
* a reference to the partition that the resource is in. For standard AWS
* regions, the partition is aws. For resources in other partitions, the
* partition is aws-partitionname. For example, the partition for resources in
* the China (Beijing) region is aws-cn.
*
* @static
* @memberof cloudfriend
* @name partition
*/
pseudo.partition = intrinsic.ref('AWS::Partition');
/**
* [The pseudo parameter AWS::DomainSuffix](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html#cfn-pseudo-param-domainsuffix),
* a reference to the suffix for a domain. For example, for the www.amazon.com
* domain, the suffix is .com. Values might differ by region, such as the suffix
* .com.cn in the China (Beijing) region.
*
* @static
* @memberof cloudfriend
* @name domainSuffix
*/
pseudo.domainSuffix = intrinsic.ref('AWS::DomainSuffix');

2

package.json
{
"name": "@mapbox/cloudfriend",
"version": "1.8.2",
"version": "1.9.0",
"description": "Helper functions for assembling CloudFormation templates in JavaScript",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -29,3 +29,4 @@ # cloudfriend

sub(str, variables) | [Fn::Sub](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html)
importValue(sharedValue) | [Fn::ImportValue](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html)
importValue(sharedValue) | [Fn::ImportValue](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html),
arn(service, suffix) | [Fn::Sub](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html) designed for an ARN

@@ -44,2 +45,4 @@ ## Pseudo parameters

stackName | [AWS::StackName](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html)
partition | [AWS::Partition](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html#cfn-pseudo-param-partition)
domainSuffix | [AWS::DomainSuffix](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html#cfn-pseudo-param-domainsuffix)

@@ -46,0 +49,0 @@ ## Other helpers

@@ -25,2 +25,4 @@ var test = require('tape');

assert.deepEqual(cloudfriend.importValue(cloudfriend.ref('Id')), { 'Fn::ImportValue': cloudfriend.ref('Id') }, 'import value with string');
assert.deepEqual(cloudfriend.arn('s3', 'my-bucket/*'), { 'Fn::Sub': ['arn:${AWS::Partition}:${service}:::${suffix}', { service: 's3', suffix: 'my-bucket/*' }] }, 's3 arn');
assert.deepEqual(cloudfriend.arn('cloudformation', 'stack/my-stack/*'), { 'Fn::Sub': ['arn:${AWS::Partition}:${service}:${AWS::Region}:${AWS::AccountId}:${suffix}', { service: 'cloudformation', suffix: 'stack/my-stack/*' }] }, 'non-s3 arn');
assert.end();

@@ -46,2 +48,4 @@ });

assert.deepEqual(cloudfriend.stackName, { Ref: 'AWS::StackName' }, 'stack');
assert.deepEqual(cloudfriend.partition, { Ref: 'AWS::Partition' }, 'stack');
assert.deepEqual(cloudfriend.domainSuffix, { Ref: 'AWS::DomainSuffix' }, 'stack');
assert.end();

@@ -48,0 +52,0 @@ });

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc