@@ -12,26 +12,30 @@ def self.run(params)
12
12
access_key = params [ :access_key ]
13
13
secret_access_key = params [ :secret_access_key ]
14
14
region = params [ :region ]
15
+ client = params [ :aws_sns_client ]
15
16
16
17
platform = params [ :platform ]
17
18
platform_name = params [ :platform_name ]
18
19
update_attributes = params [ :update_if_exists ]
20
+ attributes_override = params [ :attributes_override ]
19
21
platform_apns_private_key_path = params [ :platform_apns_private_key_path ]
20
22
platform_apns_private_key_password = params [ :platform_apns_private_key_password ]
21
23
22
24
platform_fcm_server_key = params [ :platform_fcm_server_key ]
23
25
platform_fcm_server_key ||= params [ :platform_gcm_api_key ]
24
26
25
- UI . user_error! ( "No S3 access key given, pass using `access_key: 'key'`" ) unless access_key . to_s . length > 0
26
- UI . user_error! ( "No S3 secret access key given, pass using `secret_access_key: 'secret key'`" ) unless secret_access_key . to_s . length > 0
27
- UI . user_error! ( "No S3 region given, pass using `region: 'region'`" ) unless region . to_s . length > 0
28
- UI . user_error! ( "No S3 region given, pass using `platform: 'platform'`" ) unless platform . to_s . length > 0
29
- UI . user_error! ( "No S3 region given, pass using `platform_name: 'platform_name'`" ) unless platform_name . to_s . length > 0
27
+ if client . nil?
28
+ UI . user_error! ( "No AWS access key given, pass using `access_key: 'key'`" ) unless access_key . to_s . length > 0
29
+ UI . user_error! ( "No AWS secret access key given, pass using `secret_access_key: 'secret key'`" ) unless secret_access_key . to_s . length > 0
30
+ UI . user_error! ( "No AWS region given, pass using `region: 'region'`" ) unless region . to_s . length > 0
31
+ end
32
+ UI . user_error! ( "No notification platform given, pass using `platform: 'platform'`" ) unless platform . to_s . length > 0
33
+ UI . user_error! ( "No SNS platform application name given, pass using `platform_name: 'platform_name'`" ) unless platform_name . to_s . length > 0
30
34
31
35
#
32
36
# Initialize AWS client
33
37
#
34
- client = Aws ::SNS ::Client . new (
38
+ client || = Aws ::SNS ::Client . new (
35
39
access_key_id : access_key ,
36
40
secret_access_key : secret_access_key ,
37
41
region : region
@@ -58,6 +62,13 @@ def self.run(params)
58
62
}
59
63
end
60
64
65
+ # Set additional AWS platform attributes
66
+ if attributes . nil?
67
+ attributes = attributes_override
68
+ else
69
+ attributes = attributes . merge ( attributes_override )
70
+ end
71
+
61
72
#
62
73
#
63
74
#
@@ -104,9 +115,9 @@ def self.run(params)
104
115
else
105
116
# else, updating
106
117
client . set_platform_application_attributes ( {
107
- platform_application_arn : arn ,
108
- attributes : attributes ,
109
- } )
118
+ platform_application_arn : arn ,
119
+ attributes : attributes ,
120
+ } )
110
121
UI . important ( "Updated #{ arn } " )
111
122
end
112
123
@@ -138,27 +149,47 @@ def self.details
138
149
def self . available_options
139
150
[
140
151
FastlaneCore ::ConfigItem . new ( key : :access_key ,
141
- env_name : "AWS_SNS_ACCESS_KEY" ,
142
- description : "AWS Access Key ID" ,
143
- optional : false ,
144
- default_value : ENV [ 'AWS_ACCESS_KEY_ID' ] ) ,
152
+ env_name : "AWS_SNS_ACCESS_KEY" ,
153
+ description : "AWS Access Key ID" ,
154
+ optional : true ,
155
+ sensitive : true ,
156
+ conflicting_options : [ :aws_sns_client ] ,
157
+ conflict_block : proc do |value |
158
+ UI . user_error! ( "You can't use option '#{ value . key } ' along with 'access_key'" )
159
+ end ) ,
145
160
FastlaneCore ::ConfigItem . new ( key : :secret_access_key ,
146
- env_name : "AWS_SNS_SECRET_ACCESS_KEY" ,
147
- description : "AWS Secret Access Key" ,
148
- optional : false ,
149
- default_value : ENV [ 'AWS_SECRET_ACCESS_KEY' ] ) ,
161
+ env_name : "AWS_SNS_SECRET_ACCESS_KEY" ,
162
+ description : "AWS Secret Access Key" ,
163
+ optional : true ,
164
+ sensitive : true ,
165
+ conflicting_options : [ :aws_sns_client ] ,
166
+ conflict_block : proc do |value |
167
+ UI . user_error! ( "You can't use option '#{ value . key } ' along with 'secret_access_key'" )
168
+ end ) ,
150
169
FastlaneCore ::ConfigItem . new ( key : :region ,
151
170
env_name : "AWS_SNS_REGION" ,
152
171
description : "AWS Region" ,
153
- optional : false ,
154
- default_value : ENV [ 'AWS_REGION' ] ) ,
172
+ optional : true ,
173
+ sensitive : true ,
174
+ conflicting_options : [ :aws_sns_client ] ,
175
+ conflict_block : proc do |value |
176
+ UI . user_error! ( "You can't use option '#{ value . key } ' along with 'region'" )
177
+ end ) ,
178
+ FastlaneCore ::ConfigItem . new ( key : :aws_sns_client ,
179
+ description : "AWS SNS Client, useful in case of special credentials or custom logging" ,
180
+ type : Aws ::SNS ::Client ,
181
+ optional : true ,
182
+ conflicting_options : [ :access_key , :secret_access_key , :region ] ,
183
+ conflict_block : proc do |value |
184
+ UI . user_error! ( "You can't use option '#{ value . key } ' along with 'aws_sns_client'" )
185
+ end ) ,
155
186
FastlaneCore ::ConfigItem . new ( key : :platform ,
156
- env_name : "AWS_SNS_PLATFORM" ,
157
- description : "AWS Platform" ,
158
- optional : false ,
159
- verify_block : proc do |value |
160
- UI . user_error! ( "Invalid platform #{ value } " ) unless [ 'APNS' , 'APNS_SANDBOX' , 'GCM' , 'FCM' ] . include? ( value )
161
- end ) ,
187
+ env_name : "AWS_SNS_PLATFORM" ,
188
+ description : "AWS Platform" ,
189
+ optional : false ,
190
+ verify_block : proc do |value |
191
+ UI . user_error! ( "Invalid platform #{ value } " ) unless [ 'APNS' , 'APNS_SANDBOX' , 'GCM' , 'FCM' ] . include? ( value )
192
+ end ) ,
162
193
FastlaneCore ::ConfigItem . new ( key : :platform_name ,
163
194
env_name : "AWS_SNS_PLATFORM_NAME" ,
164
195
description : "AWS Platform Name" ,
@@ -171,21 +202,30 @@ def self.available_options
171
202
env_name : "AWS_SNS_PLATFORM_APNS_PRIVATE_KEY_PASSWORD" ,
172
203
description : "AWS Platform APNS Private Key Password" ,
173
204
optional : true ,
205
+ sensitive : true ,
174
206
default_value : "" ) ,
175
207
FastlaneCore ::ConfigItem . new ( key : :platform_fcm_server_key ,
176
208
env_name : "AWS_SNS_PLATFORM_FCM_SERVER_KEY" ,
177
209
description : "AWS Platform FCM SERVER KEY" ,
178
- optional : true ) ,
210
+ optional : true ,
211
+ sensitive : true ) ,
179
212
FastlaneCore ::ConfigItem . new ( key : :platform_gcm_api_key ,
180
213
env_name : "AWS_SNS_PLATFORM_GCM_API_KEY" ,
181
214
description : "AWS Platform GCM API KEY" ,
182
215
deprecated : "Use :platform_fcm_server_key instead" ,
183
- optional : true ) ,
216
+ optional : true ,
217
+ sensitive : true ) ,
184
218
FastlaneCore ::ConfigItem . new ( key : :update_if_exists ,
185
219
env_name : "AWS_SNS_UDPATE_IF_EXISTS" ,
186
220
description : "updating certificate/key if platform_name already exists" ,
187
221
default_value : false ,
188
222
is_string : false ,
223
+ optional : true ) ,
224
+ FastlaneCore ::ConfigItem . new ( key : :attributes_override ,
225
+ env_name : "AWS_SNS_PLATFORM_ATTRIBUTES_OVERRIDE" ,
226
+ description : "additional AWS platform attributes such as EventEndpointCreated or SuccessFeedbackRoleArn" ,
227
+ default_value : { } ,
228
+ is_string : false ,
189
229
optional : true )
190
230
]
191
231
end
0 commit comments