Skip to content

Commit 6166953

Browse files
authored
Merge pull request #47 from cloudgraphdev/feature/CG-1088
feat: Add restrictionType to Cloudfront, geoRestriction
2 parents 30dd364 + 02f9853 commit 6166953

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/services/cloudfront/format.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
Origin,
55
} from 'aws-sdk/clients/cloudfront'
66
import cuid from 'cuid'
7-
import isEmpty from 'lodash/isEmpty'
87

98
import t from '../../properties/translations'
109
import { formatTagsFromMap } from '../../utils/format'
@@ -118,7 +117,7 @@ export default ({
118117
CallerReference: callerReference,
119118
DefaultRootObject: defaultRootObject,
120119
HttpVersion: httpVersion,
121-
Restrictions: { GeoRestriction: { Items: geoRestrictions = [] } } = {
120+
Restrictions: { GeoRestriction: { Items: locations = [], RestrictionType: restrictionType = ''} } = {
122121
GeoRestriction: { RestrictionType: '', Items: [], Quantity: 0 },
123122
},
124123
Logging: logging,
@@ -237,9 +236,10 @@ export default ({
237236
domainName,
238237
enabled: enabled ? t.yes : t.no,
239238
etag,
240-
geoRestrictions: !isEmpty(geoRestrictions)
241-
? geoRestrictions.join(',')
242-
: 'none',
239+
geoRestriction: {
240+
restrictionType,
241+
locations,
242+
},
243243
httpVersion,
244244
ipv6Enabled: isIpv6Enabled ? t.yes : t.no,
245245
lastModified: lastModified.toISOString(),

src/services/cloudfront/schema.graphql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type awsCloudfront implements awsBaseService @key(fields: "id") {
1010
ipv6Enabled: String @search(by: [hash])
1111
defaultRootObject: String @search(by: [hash])
1212
webAclId: String @search(by: [hash])
13-
geoRestrictions: String @search(by: [hash, regexp])
13+
geoRestriction: awsCloudfrontGeoRestriction
1414
customErrorResponses: [awsCloudfrontCustomErrorResponse]
1515
defaultCacheBehavior: awsCloudfrontCacheBehavior
1616
orderedCacheBehaviors: [awsCloudfrontCacheBehavior]
@@ -94,3 +94,8 @@ type awsCloudfrontLoggingConfig {
9494
bucket: String @search(by: [hash, regexp])
9595
prefix: String @search(by: [hash, regexp])
9696
}
97+
98+
type awsCloudfrontGeoRestriction {
99+
restrictionType: String @search(by: [hash, regexp])
100+
locations: [String] @search(by: [hash, regexp])
101+
}

src/types/generated.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ export type AwsCloudfront = AwsBaseService & {
749749
elb?: Maybe<Array<Maybe<AwsElb>>>;
750750
enabled?: Maybe<Scalars['String']>;
751751
etag?: Maybe<Scalars['String']>;
752-
geoRestrictions?: Maybe<Scalars['String']>;
752+
geoRestriction?: Maybe<AwsCloudfrontGeoRestriction>;
753753
httpVersion?: Maybe<Scalars['String']>;
754754
ipv6Enabled?: Maybe<Scalars['String']>;
755755
lastModified?: Maybe<Scalars['String']>;
@@ -797,6 +797,11 @@ export type AwsCloudfrontCustomOriginConfig = {
797797
originSslProtocols?: Maybe<AwsCloudfrontOriginSslProtocols>;
798798
};
799799

800+
export type AwsCloudfrontGeoRestriction = {
801+
locations?: Maybe<Array<Maybe<Scalars['String']>>>;
802+
restrictionType?: Maybe<Scalars['String']>;
803+
};
804+
800805
export type AwsCloudfrontLoggingConfig = {
801806
bucket?: Maybe<Scalars['String']>;
802807
enabled?: Maybe<Scalars['Boolean']>;

0 commit comments

Comments
 (0)